excel as database

  • Thread starter Thread starter alanq
  • Start date Start date
A

alanq

Hi guys,
I am a newbie to VBA.
I am trying to use excel as a database.
I want to search for some value in the database, copy the whole row
and paste on another worksheet for viewing.
The qn is how do i select a range from a cell so i can do a find for
the value and then copy the row in which the cell is, and then paste
on another worksht?

pls advise
thanks
alan
 
to reference the database

set rng = Range("A1").CurrentRegion

a specific column in that rng

Dim rng as Range
Dim rng1 as Range
Dim sStr as String
set rng1 = nothing
set rng = Range("A1").CurrentRegion.Columns(3).Cells
sStr = "ABCD"
set rng1 = rng.Find(What:=sStr)
if not rng1 is nothing then
rng1.EntireRow.copy Destination:= _
Worksheets("Sheet3").Cells(rows.count,1).End(xlup)(2)
End if

See help on the find method for additional arguments and/or turn on the
macro recorder while you do a find manually.
 
Back
Top