Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA code for pressing "down arrow" in recording macro

I'm recording a copy/paste macro, using 'end' 'down arrow' to get to bottom
of list and then press the down arrow. When I press the down arrow, I just
want the code to appear for pressing the down arrow, but instead it puts a
range command with a specific cell location, like A1046. What can I replace
this statement with, so I can just go down one cell, so it can start the
copy/paste? Here's the code:
(I want to keep this code, but just change the "Range("A1041").Select" part
to reflect pressing the down arrow key, instead of actually giving me a
"cell" location.)

Can anyone help? thx Dotti


Application.Goto Reference:="DataOtherEquip"
Selection.Copy
Sheets("SQL Equip").Select
Range("A2").Select
Selection.End(xlDown).Select
' note for Dotti - change this next statement to reflect 'down' one cell
instead of a range

Range("A1041").Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Other Equip").Select
Range("A1").Select
Application.CutCopyMode = False
Sheets("SQL Equip").Select
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA code for pressing "down arrow" in recording macro

Selection.End(xlDown).offset(1,0).select

And delete that next statement.

You could also drop the .select's:

Dim RngToCopy as range
dim DestCell as Range

set rngtocopy = worksheets("whateversheetname").range("DataOtherEq uip")

with workSheets("SQL Equip")
set destcell = .range("a2").end(xldown).offset(1,0)
end with

Rngtocopy.copy _
destination:=destcell

Application.CutCopyMode = False



Dotti wrote:

I'm recording a copy/paste macro, using 'end' 'down arrow' to get to bottom
of list and then press the down arrow. When I press the down arrow, I just
want the code to appear for pressing the down arrow, but instead it puts a
range command with a specific cell location, like A1046. What can I replace
this statement with, so I can just go down one cell, so it can start the
copy/paste? Here's the code:
(I want to keep this code, but just change the "Range("A1041").Select" part
to reflect pressing the down arrow key, instead of actually giving me a
"cell" location.)

Can anyone help? thx Dotti

Application.Goto Reference:="DataOtherEquip"
Selection.Copy
Sheets("SQL Equip").Select
Range("A2").Select
Selection.End(xlDown).Select
' note for Dotti - change this next statement to reflect 'down' one cell
instead of a range

Range("A1041").Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Other Equip").Select
Range("A1").Select
Application.CutCopyMode = False
Sheets("SQL Equip").Select
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA code for pressing "down arrow" in recording macro

Thanks, but that didn't work. Did I do something wrong? Here's the code:

I think we're close; any more suggestions??? Thanks for your help! Dotti


Application.Goto Reference:="DataOtherEquip"
Selection.Copy
Sheets("SQL Equip").Select
Range("A2").Select
Selection.End(xlDown).Select
' note for Dotti - change this next statement to reflect 'down' one cell
instead of a range

' Range("A1041").Select
Selection.End(xlDown).Offset(1, 0).Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Other Equip").Select
Range("A1").Select
Application.CutCopyMode = False
Sheets("SQL Equip").Select
End Sub



"Dave Peterson" wrote:

Selection.End(xlDown).offset(1,0).select

And delete that next statement.

You could also drop the .select's:

Dim RngToCopy as range
dim DestCell as Range

set rngtocopy = worksheets("whateversheetname").range("DataOtherEq uip")

with workSheets("SQL Equip")
set destcell = .range("a2").end(xldown).offset(1,0)
end with

Rngtocopy.copy _
destination:=destcell

Application.CutCopyMode = False



Dotti wrote:

I'm recording a copy/paste macro, using 'end' 'down arrow' to get to bottom
of list and then press the down arrow. When I press the down arrow, I just
want the code to appear for pressing the down arrow, but instead it puts a
range command with a specific cell location, like A1046. What can I replace
this statement with, so I can just go down one cell, so it can start the
copy/paste? Here's the code:
(I want to keep this code, but just change the "Range("A1041").Select" part
to reflect pressing the down arrow key, instead of actually giving me a
"cell" location.)

Can anyone help? thx Dotti

Application.Goto Reference:="DataOtherEquip"
Selection.Copy
Sheets("SQL Equip").Select
Range("A2").Select
Selection.End(xlDown).Select
' note for Dotti - change this next statement to reflect 'down' one cell
instead of a range

Range("A1041").Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Other Equip").Select
Range("A1").Select
Application.CutCopyMode = False
Sheets("SQL Equip").Select
End Sub


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA code for pressing "down arrow" in recording macro

Application.Goto Reference:="DataOtherEquip"
Selection.Copy
Sheets("SQL Equip").Select
Range("A2").Select
Selection.End(xlDown).Offset(1, 0).Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Other Equip").Select
Range("A1").Select
Application.CutCopyMode = False
Sheets("SQL Equip").Select
End Sub

Did you think about trying the other suggestion. Lots of times, it's easier to
see what's happening if there aren't .select's in the code.



Dotti wrote:

Thanks, but that didn't work. Did I do something wrong? Here's the code:

I think we're close; any more suggestions??? Thanks for your help! Dotti

Application.Goto Reference:="DataOtherEquip"
Selection.Copy
Sheets("SQL Equip").Select
Range("A2").Select
Selection.End(xlDown).Select
' note for Dotti - change this next statement to reflect 'down' one cell
instead of a range

' Range("A1041").Select
Selection.End(xlDown).Offset(1, 0).Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Other Equip").Select
Range("A1").Select
Application.CutCopyMode = False
Sheets("SQL Equip").Select
End Sub

"Dave Peterson" wrote:

Selection.End(xlDown).offset(1,0).select

And delete that next statement.

You could also drop the .select's:

Dim RngToCopy as range
dim DestCell as Range

set rngtocopy = worksheets("whateversheetname").range("DataOtherEq uip")

with workSheets("SQL Equip")
set destcell = .range("a2").end(xldown).offset(1,0)
end with

Rngtocopy.copy _
destination:=destcell

Application.CutCopyMode = False



Dotti wrote:

I'm recording a copy/paste macro, using 'end' 'down arrow' to get to bottom
of list and then press the down arrow. When I press the down arrow, I just
want the code to appear for pressing the down arrow, but instead it puts a
range command with a specific cell location, like A1046. What can I replace
this statement with, so I can just go down one cell, so it can start the
copy/paste? Here's the code:
(I want to keep this code, but just change the "Range("A1041").Select" part
to reflect pressing the down arrow key, instead of actually giving me a
"cell" location.)

Can anyone help? thx Dotti

Application.Goto Reference:="DataOtherEquip"
Selection.Copy
Sheets("SQL Equip").Select
Range("A2").Select
Selection.End(xlDown).Select
' note for Dotti - change this next statement to reflect 'down' one cell
instead of a range

Range("A1041").Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Other Equip").Select
Range("A1").Select
Application.CutCopyMode = False
Sheets("SQL Equip").Select
End Sub


--

Dave Peterson


--

Dave Peterson
Reply
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
Opening the Macro "Stop Recording" tool bar Oak Tree Excel Programming 1 September 16th 06 04:12 AM
colour fonts revert to black when pressing "Enter" BAB Excel Discussion (Misc queries) 5 February 22nd 06 06:45 PM
How do I turn on "pressing enter goes to the next cell" option? Hollywood Excel Discussion (Misc queries) 6 December 20th 05 09:10 PM
Pressing "Enter" to run macro grin2000[_9_] Excel Programming 10 June 22nd 04 02:38 PM
Problem- Recording macros for "file save" and "File open" tritaco Excel Programming 1 April 22nd 04 06:15 PM


All times are GMT +1. The time now is 05:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"