Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Macro's Pasting into continous rows

I'm trying to make a Macro that once i click the button it will copy from A1
and paste into B2. the next time i click the Button i still want it to copy
from A1 but paste in B3, then B4..B5 so on and so forth!
is this possible?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Macro's Pasting into continous rows

Hi Euan-

There are better ways, but a quick and easy way would be to use a Static
variable.

Sub CopyCell()

Static r As Integer
Range("A1").Select
Selection.Copy
Cells(r + 2, 2).Select
ActiveSheet.Paste
r = r + 1

End Sub

"Euan Ritchie" wrote:

I'm trying to make a Macro that once i click the button it will copy from A1
and paste into B2. the next time i click the Button i still want it to copy
from A1 but paste in B3, then B4..B5 so on and so forth!
is this possible?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macro's Pasting into continous rows

Why not just make it automatic when you change cell a1. Right click sheet
tabview codecopy\paste this. Now when you change cell a1 the data will
goto the next available row in col B

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < Range("a1").Address Then Exit Sub
dlr = Cells(Rows.Count, "b").End(xlUp).Row + 1
Target.Copy Cells(dlr, "b")
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Euan Ritchie" wrote in message
...
I'm trying to make a Macro that once i click the button it will copy from
A1
and paste into B2. the next time i click the Button i still want it to
copy
from A1 but paste in B3, then B4..B5 so on and so forth!
is this possible?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Macro's Pasting into continous rows

How do i alter this so that the first paste would be in row B5 say.

"redeagle" wrote:

Hi Euan-

There are better ways, but a quick and easy way would be to use a Static
variable.

Sub CopyCell()

Static r As Integer
Range("A1").Select
Selection.Copy
Cells(r + 2, 2).Select
ActiveSheet.Paste
r = r + 1

End Sub

"Euan Ritchie" wrote:

I'm trying to make a Macro that once i click the button it will copy from A1
and paste into B2. the next time i click the Button i still want it to copy
from A1 but paste in B3, then B4..B5 so on and so forth!
is this possible?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Macro's Pasting into continous rows

Hi Don-

Good tip. I'm going to steel that for one of my projects and implement a
Select Case.

Select Case Target.Address
Case Range("A1").Address
dlr = Cells(Rows.Count, "b").End(xlUp).Row + 1
Target.Copy Cells(dlr, "b")
Case Else

End Select

John

"Don Guillett" wrote:

Why not just make it automatic when you change cell a1. Right click sheet
tabview codecopy\paste this. Now when you change cell a1 the data will
goto the next available row in col B

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < Range("a1").Address Then Exit Sub
dlr = Cells(Rows.Count, "b").End(xlUp).Row + 1
Target.Copy Cells(dlr, "b")
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Euan Ritchie" wrote in message
...
I'm trying to make a Macro that once i click the button it will copy from
A1
and paste into B2. the next time i click the Button i still want it to
copy
from A1 but paste in B3, then B4..B5 so on and so forth!
is this possible?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Macro's Pasting into continous rows

Cells(r + 5, 2).Select

But a better way is to use Don's suggestion using the Worksheet_Change()
event.

John

"Euan Ritchie" wrote:

How do i alter this so that the first paste would be in row B5 say.

"redeagle" wrote:

Hi Euan-

There are better ways, but a quick and easy way would be to use a Static
variable.

Sub CopyCell()

Static r As Integer
Range("A1").Select
Selection.Copy
Cells(r + 2, 2).Select
ActiveSheet.Paste
r = r + 1

End Sub

"Euan Ritchie" wrote:

I'm trying to make a Macro that once i click the button it will copy from A1
and paste into B2. the next time i click the Button i still want it to copy
from A1 but paste in B3, then B4..B5 so on and so forth!
is this possible?

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
Sum of continous cell Man Excel Worksheet Functions 3 July 14th 08 05:45 PM
Copy pasting Rows, but need to Delete any Shapes/Pictures that are within copied rows Corey Excel Programming 2 August 1st 07 02:02 AM
Hide Macro's in Toolbar / Macro's list sparx Excel Discussion (Misc queries) 2 May 6th 06 08:53 PM
deleting rows in a non-continous range kiat Excel Programming 0 August 22nd 03 03:23 PM
deleting rows in a non-continous range Michael Tomasura Excel Programming 0 August 22nd 03 03:58 AM


All times are GMT +1. The time now is 09:55 PM.

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"