Archive for the ‘Learn Excel Macros’ Category

How to search through array in Visual Basic?

Wednesday, April 25th, 2012

In my program I have an array that contains the results of the rolls of a die. The user input how many times they wanted it rolled. I need to search through that array to find how many times a certain number shows up (also one that the user chose) to find it’s probability.

So I’d like a loop (or something else, but a loops is the only thing I can think of) to be able to loop through the array and keep track of how many times it shows up. I was going to use UBound and LBound, but because I’m finding the probability in a different procedure it won’t work.

Here’s what I have

Public Class Form1
Dim intTosses As Integer
Dim ResultTosses() As Integer
Dim intFindProb As Integer ‘This is the number that the user wants to see the probability for

Private Sub txtNumTosses_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNumTosses.TextChanged
Dim intcounter As Integer
Dim intResult As Integer
intTosses = Val(txtNumTosses.Text)
ReDim ResultTosses(intTosses)

For intcounter = 1 To intTosses
intResult = Int(6 * Rnd(1) + 1)
ResultTosses(intcounter) = intResult
Next
lblProbability.Text = ResultTosses(intTosses)

End Sub

Private Sub txtNumProbability_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNumProbability.TextChanged
Dim intpcounter As Integer
intFindProb = (Val(txtNumProbability.Text)
‘****Here is where I need to find out how many of intFindProb are in my ResultTosses Array****
If

Next
End Sub
End Class

If you could give a different example or just explain it that would be good, as it is something I need to pass in so I would like to put it together myself (we are allowed to ask for help, but the teacher is always busy), but I’m fairly lost so I’ll take what I can get.

The following code will allow the user to enter the number of rolls for one die that he wants to place in an array; and the two search numbers he desires to see howmany times they appear in the array. The number of occurrances for the two search numbers will appear in labels 1 and 2. You can use these 2 numbers for any purpose.

There is a button, 3 text boxes and 2 labels on my form.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim HowMany As Integer
Dim Array(500) As Integer
Dim MaxIndex As Integer
Dim SearchNum1 As Integer = Val(TextBox2.Text)
Dim SearchNum2 As Integer = Val(TextBox3.Text)
Dim SearchNum1Cnt, SearchNum2Cnt As Integer
If IsNumeric(TextBox1.Text) Then
HowMany = Val(TextBox1.Text)
MaxIndex = HowMany – 1
End If
Dim Rnd As New Random
For i = 0 To MaxIndex
Array(i) = Rnd.Next(1, 7)
Next
For i = 0 To MaxIndex
‘MsgBox(i & " " & Array(i) & " " & SearchNum1)
If Array(i) = SearchNum1 Then
SearchNum1Cnt += 1
End If
If Val(Array(i)) = SearchNum2 Then
SearchNum2Cnt += 1
End If
Next
Label1.Text = SearchNum1Cnt
Label2.Text = SearchNum2Cnt
End Sub

End Class

How to write a VBA/Excel stopwatch?

Wednesday, April 25th, 2012

I need a stopwatch for a an excel userform I will be using. I need the stop watch to use the format "mm:ss" and start/reset with the same button. I am new to VBA, and do not know how to do this, can anyone provide me a solution?

You can’t do that for the device since there is no such feature available…

Good luck!

How can I use VBA in Excel to look up words in the ‘Word’ dictionary/thesaurus?

Wednesday, April 25th, 2012

I am experimenting with language parsing in Excel. I would like to use the dictionary and/or thesaurus in Word to look up definitions/synonyms for words that I have in my spreadsheet. I know that I can reference Word objects from VBA. Can anyone point me to some code that would help me do this please?

In Excel 2010, just hit F7 (like you can do in Word, etc) – that will launch the same spell checker. No additional code required.

Excel macro emploi du temps

Monday, April 23rd, 2012

Niveau débutant: Ce tutoriel explique comment créer une macro simple. D’autres vidéos sur agi67.fr.

Duration : 0:3:12

(more…)

Technorati Tags: , ,

Record and Edit an Excel Advanced Filter Macro

Monday, April 23rd, 2012

http://www.contextures.com/xladvfilter01.html
Use an Excel Advanced Filter to copy specific items from a list, to a new location.

The extracted data will not update automatically, so record the steps as you use the Advanced Filter feature.

Then, edit the recorded macro, to make it flexible, in case the source data range changes.

See the steps in this short Excel video tutorial.

Duration : 0:5:26

(more…)

Technorati Tags: , , , , , , , , , , , , ,

Curso de Excel Criando Macros e Botões

Monday, April 23rd, 2012

Curso de Excel 2003 – Aprenda nesta video aula a finalidade das macros e a como criar uma macro e a defini-la em um botão de Comando. Para Adquirir o Nosso DVD de Excel é so entrar em contato pelo e-mail: classeatreinamentos@yahoo.com.br ou pelo msn: classeatreinamento@hotmail.com . Para conhecer nosso catalogo de produtos e poder fazer compras pela internet, acesse a nossa loja virtual www.CLASSEACURSOS.com.br

Duration : 0:7:25

(more…)

Technorati Tags: , , , , , , ,

Buscar y filtrar con excel – macros para buscar rapidamente con excel Filtro automaticos

Monday, April 23rd, 2012

Esta es una plantilla creada en Excel, para buscar y filtrar rápidamente listados creados en una hoja de Excel. Funciona ingresando las palabra o palabras de búsqueda, la macro hace dos tareas busca y filtra con un clic. Si desea hacer tu propio proyecto basado en esta plantilla usa la funcion Cells.Find y Selection.AutoFilter.

Duration : 0:6:13

(more…)

Technorati Tags: , , , , , ,

Excel (Macros / Botões / Guias) – www.jeffersoncosta.com.br

Monday, April 23rd, 2012

www.jeffersoncosta.com.br
Essa é uma vídeo aula de Microsoft Excel Avançado 2010.
O objetivo aqui é ensinar macros / botões / guias de forma simples.
twitter: ProfJcosta

Duration : 0:4:21

(more…)

Technorati Tags: , , , , , , , , , , , , , , , ,

Excel VBA tutorial 28 GetSaveAsFilename.flv

Monday, April 23rd, 2012

How to open up a saveas dialog box

Duration : 0:8:50

(more…)

Technorati Tags: , , , , , , , , , , , , , , , , , , ,

VBA – Excel If Function in VBA code

Monday, April 23rd, 2012

Excel If Function in VBA code. This VBA Function does exactly what the Excel If Function does.

Code:

Function ifCode(s1 As String, s2 As Variant, s3 As Variant)

tst = Evaluate(s1)

If tst = True Then
ifCode = s2
Else
ifCode = s3
End If

End Function

Duration : 0:4:24

(more…)

Technorati Tags: , , , , , , , , , , , , ,