Well, for one thing I would prefer to use option buttons
rather than do all the checks for the checkboxes. If you
only need one picked, that's the way to go. Further, you
MAY be able to return the value(s) in another column if
it would be easier to use XL functions (assuming you
really don't have any use for the VBA). Or if you need it
to come up in a dialog or something, VBA would be
quite useful at that point. Other than that, I don't have a
lot of useful suggestions at the moment.
G.
________________________________
From: tariq_rahmalan <tariq_rahmalan@yahoo.com>
To: ExcelVBA@yahoogroups.com
Sent: Tuesday, May 1, 2012 10:03 PM
Subject: [ExcelVBA] Re: Finding several rows value according to data values
Anyone willing to help? Your kindness are really appreciated :)
--- In ExcelVBA@yahoogroups.com, "tariq_rahmalan" <tariq_rahmalan@...> wrote:
>
> Hi friends. I having some difficulties in coding my vba. Hopefully all of you may guide me. Here are some of my data in excel.
>
> A B
>
> 1. Amirul 12345
>
> 2. Norlela 12121
>
> 3. Amirul 23456
>
> 4. Amirul 45678
>
> I do have several checkbox and i want to find row's value according to data which I put in certain CheckBox field. Each time I run, I would like to have different value if the data is the same value. Eg: If I put value on CheckBox is "Amirul", I would like the coding give me answer "1". When I run again, vba give me answer "3". Then next time i run answer would be "4". Unless there is no longer same value in the database.Can anyone help me to code the coding? I'll put in capital letter where i wanna code to be placed.
>
> Here my initial coding :
>
>
> Private Sub CommandButton9_Click()
> Dim ws As Worksheet
> Dim xfilter As String
> Dim xFind, xRow As Range
> Set ws = Worksheets("Rekod")
>
> 'to confirm only 1 checkbox are clicked
> If CheckBox1.Value = True And _
> CheckBox2.Value And _
> CheckBox3.Value = True Then
> MsgBox "Sila Klik Satu Pilihan Sahaja"
>
> ElseIf CheckBox1.Value = True And _
> CheckBox2.Value = True Then
> MsgBox "Sila Klik Satu Pilihan Sahaja"
>
> ElseIf CheckBox1.Value = True And _
> CheckBox3.Value = True Then
> MsgBox "Sila Klik Satu Pilihan Sahaja"
>
> ElseIf CheckBox2.Value = True And _
> CheckBox3.Value = True Then
> MsgBox "Sila Klik Satu Pilihan Sahaja"
>
> End If
>
>
> ' to determine filter
> If CheckBox1.Value = True Then
> xfilter = spk.Value
> End If
>
> If CheckBox2.Value = True Then
> xfilter = penerima.Value
> End If
>
> If CheckBox3.Value = True Then
> xfilter = utmfin.Value
> End If
>
> 'to find exact data
> >>>> HERE I WANT TO PUT THE CODING. MY CODING WAS TOTALLY WRONG..>>>
> xRow = xRow + 1
> Set xFind = ws.Range("Database" - xRow).Find(what:=xfilter, MatchCase:=True)
>
> If xFind Is Nothing Then
> MsgBox "Tiada Rekod Dijumpai"
>
> Else
> MsgBox xFind.Row
> 'to show relevant data
>
> End If
>
>
>
> End Sub
>
[Non-text portions of this message have been removed]
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar