Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Change Macro?

I got this macro here which works well:
Private Sub ListBox1_Change()
With Me.ListBox1
If .ListIndex -1 Then
'MsgBox .List(.ListIndex, 1)
ThisWorkbook.FollowHyperlink _
Address:="Http://" & .List(.ListIndex, 1)
End If
End With
End Sub

Private Sub UserForm_Initialize()
Dim cell As Range
Dim sh As Worksheet

With Me
.ListBox1.RowSource = ""
.ListBox1.ColumnCount = 3
.ListBox1.Clear
End With

Set sh = Worksheets("Ark1")

For Each cell In sh.Range("A10:A250")
If cell.Value = sh.Range("A5").Value Then
With UserForm
.ListBox1.AddItem cell.Value
.ListBox1.List(.ListBox1.ListCount - 1, 1) _
= cell.Offset(0, 2).Value
.ListBox1.List(.ListBox1.ListCount - 1, 2) _
= cell.Offset(0, 5).Value
End With
End If
Next

End Sub


I want to change macro becauseof this:
I have made Useform with 2 frame and inside of each frame two option
button. I have also one textbox.
At the end I have one commandbutton (FIND). I want to do this:
When USER make choise in this two frames and make input in textbox. And
push commanbutton(FIND) then if this 3 words appear in samme row then I
want row display in listbox. It sholud be searched in a whole workbook.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Change Macro?

Look in help at the FindNext method of the range object. The sample code
shows how to search for multiple occurances of a target. Look for one of
your cells. Then each time you find it, check the two other cells in that
row for the specific condition which must be satisfied. If the conditions
are met, do the additem. continue the search.

--
Regards,
Tom Ogilvy

"Alen32" wrote in message
lkaboutsoftware.com...
I got this macro here which works well:
Private Sub ListBox1_Change()
With Me.ListBox1
If .ListIndex -1 Then
'MsgBox .List(.ListIndex, 1)
ThisWorkbook.FollowHyperlink _
Address:="Http://" & .List(.ListIndex, 1)
End If
End With
End Sub

Private Sub UserForm_Initialize()
Dim cell As Range
Dim sh As Worksheet

With Me
.ListBox1.RowSource = ""
.ListBox1.ColumnCount = 3
.ListBox1.Clear
End With

Set sh = Worksheets("Ark1")

For Each cell In sh.Range("A10:A250")
If cell.Value = sh.Range("A5").Value Then
With UserForm
.ListBox1.AddItem cell.Value
.ListBox1.List(.ListBox1.ListCount - 1, 1) _
= cell.Offset(0, 2).Value
.ListBox1.List(.ListBox1.ListCount - 1, 2) _
= cell.Offset(0, 5).Value
End With
End If
Next

End Sub


I want to change macro becauseof this:
I have made Useform with 2 frame and inside of each frame two option
button. I have also one textbox.
At the end I have one commandbutton (FIND). I want to do this:
When USER make choise in this two frames and make input in textbox. And
push commanbutton(FIND) then if this 3 words appear in samme row then I
want row display in listbox. It sholud be searched in a whole workbook.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Change Macro?

I found this in help but how to insert 3 words from my userform instead of
number 2?

This example finds all cells in the range A1:A500 that contain the value 2
and makes those cells gray.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Change Macro?

Is that search for an amalgam of the 3 words, one after the other, all three
in related cells (if so, what is the relationship), or any one of the three?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alen32" wrote in message
lkaboutsoftware.com...
I found this in help but how to insert 3 words from my userform instead of
number 2?

This example finds all cells in the range A1:A500 that contain the value 2
and makes those cells gray.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Change Macro?

I make database of my articles in excell. User can choose with
optionbutton.
frame 1
horse
pig
frame2
danish
foreign
and
text box is free but only one word.
Now you have tree words ex. horse, danish and Aminoacids (input ex. from
textbox).
this three words can be found in samme row and I want to display these row
in listbox.
Words are in samme row but in different columns.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use Macro To Change Which Macro Assigned To Command Button CVinje Excel Discussion (Misc queries) 0 May 25th 10 09:55 PM
Insert row at change macro - how to change it. cathit Excel Discussion (Misc queries) 1 March 26th 09 07:14 PM
macro that will change the font of a cell if i change a value jk Excel Discussion (Misc queries) 2 July 29th 08 04:39 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
How do I change macro text with another macro? Eric Excel Discussion (Misc queries) 4 April 27th 05 11:20 PM


All times are GMT +1. The time now is 07:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"