View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default how do i tell a macro to begin in the current cell?

Maybe something similar to this? You will need to change the Criteria to
what you are looking for. Also, review the parameters of the Find method. I
made assumptions about how you want to perform the search (refer to help in
VBA for the Find Method and its parameters). Also, you may need to change
the destination for the transposed data. I put it in Sheet2, cell A1.

Sub Test()
Const Criteria As String = "Joe"
Dim rngFound As Range

Set rngFound = Cells.Find(what:=criteria, _
after:=Cells(1, 1), LookIn:=xlValues, _
lookat:=xlWhole, searchorder:=xlByRows, _
searchdirection:=xlNext, MatchCase:=False, _
matchbyte:=False)

rngFound.EntireRow.Copy
Worksheets("Sheet2").Range("A1").PasteSpecial Paste:=xlAll, _
Operation:=xlPasteSpecialOperationNone, skipblanks:=false, _
Transpose:=True
Application.CutCopyMode = False

Worksheets("Sheet2").PrintOut
End Sub

"marwildfw" wrote:

I want to use the search function to find specific data and then use a macro
to select the entire row and transpose it into a column and then print the
data.

The macro works but it selects the same row every time. I want to know how
to tell the macro to start in the current cell.

I use the record function to create the macro, so a simple solution would be
appreciated.