PDA

View Full Version : How to write this kind of code



jackal_yap
09-28-2008, 07:48 PM
hi,

i key in the data in a cells and i want to find all data in the cells then copy whole row of the data.

Demosthine
09-28-2008, 08:28 PM
Hey there Jackal.

I think you can find what you're looking for if you look at this thread. It searches a certain column for values greater than 0 and copies the row to a separate sheet.

If you need more help, let me know.
Scott

jackal_yap
09-29-2008, 12:00 AM
hi,

erm...........
how if i want let user to key in then search with it then copy whole row.
like user key in mouse then all kind of mouse will show just like filter.

Bob Phillips
09-29-2008, 12:03 AM
WOuld it just be one column, or could it be in many?

jackal_yap
09-29-2008, 12:31 AM
Hi,

it could be many column.
after search complete i want to hide all difference data just show the data same with user key in.

Thank for helping

Bob Phillips
09-29-2008, 12:36 AM
Sorry, I don't understand this bit ... i want to hide all difference data just show the data same with user key in.

jackal_yap
09-29-2008, 12:41 AM
erm......
ya
but it can show whole Row that with the same data
understand?

jackal_yap
09-29-2008, 12:47 AM
can write kind of code?

MaximS
09-29-2008, 01:06 AM
post sample workbook with 2 sheets:

- what you have
- what you need

jackal_yap
09-29-2008, 01:25 AM
i don't knw how to insert the PICTURE

jackal_yap
09-29-2008, 01:52 AM
Thanks for let me knw how to attach file
10162

jackal_yap
09-29-2008, 02:02 AM
now i got this kind of code

Sub c()
Dim inpt As String
Dim i As Integer
inpt = InputBox("Text to Find", "FIND")
With ActiveSheet.Range("A1:IV65536")
Set x = .Find(inpt, LookIn:=xlValues)
End With
Range("3:5").Select
Selection.EntireRow.Hidden = True
Range(x.Address).Select
Selection.EntireRow.Hidden = False
End Sub

but there is some limitation can anyone help me to improve the limitation
this code can only search the 1st one its see then all will go to hidden
how to change if i got few same data? like the TOYOTA in sample

Edited by Aussiebear: Please enclose your code by using the vba button.

Bob Phillips
09-29-2008, 02:15 AM
Sub c()
Dim inpt As String
Dim x As Range
Dim firstaddress As String
inpt = InputBox("Text to Find", "FIND")
With ActiveSheet.Range("A1:IV65536")
Set x = .Find(inpt, LookIn:=xlValues)
If Not x Is Nothing Then
firstaddress = x.Address
Do

x.EntireRow.Hidden = False
Set x = .FindNext(x)
Loop While Not x Is Nothing And x.Address <> firstaddress
End If
End With

End Sub

MaximS
09-29-2008, 02:17 AM
Actually you don't need any VBA code for that simple autofilter should do the job.

See attachments for details.

jackal_yap
09-29-2008, 02:24 AM
Thanks