LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default how do i tell a macro to begin in the current cell?

VBA is over my head. I use the cheat method and let the macro copy what I
want to do. Here is the macro I ended up with and it works! The search is
not part of the macro. I am searching through 30,000 addresses for a
specific one and then printing the results based on the cell the address is
found in.

ActiveCell.Rows("1:1").EntireRow.Select
ActiveCell.Activate
Selection.Copy
Sheets("PRINT").Select
ActiveCell.Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=True
ActiveCell.Offset(0, -1).Range("A1:B44").Select
Application.CutCopyMode = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=3, Collate:=True
ActiveCell.Offset(0, 1).Range("A1:A44").Select
Selection.ClearContents
ActiveCell.Select
Sheets("LBE_Mailfile_May_2006_PRINT").Select
Application.Goto Reference:="R2C4"
End Sub


"JMB" wrote:

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.

 
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
getting a simple macro to begin execution on the selected cell bolchman Excel Discussion (Misc queries) 2 February 2nd 07 08:59 PM
Macro to run relative to current selected cell MahD Excel Discussion (Misc queries) 3 December 11th 06 06:18 AM
In Excel 2002 macro, go to cell in current row. jannkatt Excel Programming 1 November 28th 05 08:29 PM
Want macro to select current cell rdaugherty Excel Programming 9 October 13th 05 04:35 PM
Macro to copy current cell [email protected] Excel Programming 4 May 17th 05 09:15 PM


All times are GMT +1. The time now is 04:21 AM.

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"