Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy Selected Range

Status
Not open for further replies.

Oliversmo

IS-IT--Management
Feb 27, 2001
14
US
I am using the following macro to find a selected range, however the macro only copies the first cell from the 'find' statement not the entire range that is highlighted. Any ideas?

Sub Macro4()
'
' Macro4 Macro
' Macro recorded 9/25/01 by hclark
'
Cells.Find(What:="broker", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate

SendKeys "+({end}{down})", False
SendKeys "+({end}{right})", False

Selection.Copy
End Sub
 
How are you running this macro?

It works for me.

Make sure you are just hitting play. The sheet must be active otherwise the Sendkeys will be run on what ever has focus.
 
that was supposed to say

"Make sure you are NOT just hitting play!"
 
I set up a custom icom to run that particular macro and it will select the desired area but only copy the initial cell.
 
Replace the last three lines of code with this:
Code:
Dim SelectThisRange As Range

      Set SelectThisRange = Range(ActiveCell, _
                            ActiveCell.End(xlToRight))
      Range(SelectThisRange, _
            SelectThisRange.End(xlDown)).Copy
You should probably move the
Code:
Dim
statement to the top of the procedure, though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top