PDA

View Full Version : Solved: search across multiple worksheets



simora
01-10-2010, 04:15 AM
Trying to search across multiple worksheets for a value that I put into a userform textBox4
I can get the address, but how do I fill the form with values from the same row from the found address.
It finds a match like
firstAddress = c.Address
This correctly shows me the sheet name, row & column
MsgBox (sh.Name & " " & c.Row & " " & c.Column)
From this information, I need to have textBox3.valu be 1 column to the left & textBox2 be 2 columns to the left of the found address.

There should only be 1 match, but if there's more, then the error should show in TextBox1

Thanks

Bob Phillips
01-10-2010, 04:37 AM
Try

firstAddress = c.Address(,,,True)

Simon Lloyd
01-10-2010, 05:09 AM
Trying to search across multiple worksheets for a value that I put into a userform textBox4
I can get the address, but how do I fill the form with values from the same row from the found address.
It finds a match like
firstAddress = c.Address
This correctly shows me the sheet name, row & column
MsgBox (sh.Name & " " & c.Row & " " & c.Column)
From this information, I need to have textBox3.valu be 1 column to the left & textBox2 be 2 columns to the left of the found address.

There should only be 1 match, but if there's more, then the error should show in TextBox1

Thankstry thisMe.TextBox3.value = Range(c.address).offset(0,-1).value
Me.TextBox2.value = Range(c.address).offset(0,-2).valueBut to be honest you are best supplying the code you are working with!

simora
01-10-2010, 05:45 AM
Thanks All:

After much trial & error:



firstAddress = c.Address
With c
TextBox1.Value = .Offset(0, -2).Value
TextBox2.Value = .Offset(0, -1).Value
End With


Appreciated your help.

simora
01-10-2010, 05:48 AM
OOPS!
Posted the incorrect TextBoxes, but Simon had the correct stuff.
It was the format that created my problems.

Thanks