![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Join Date: Apr 2002
Location: iceland
Posts: 124
|
Hi guys.
I cells A1:A10 i have numbers. And in cell B1 you can enter a number, I need a macro to copy the value in cell B1 and paste it in the next empty cell in column A (in this case A11)and the next value would be pasted in cell A12 and so on.. (ps. this is a simple version of my problem) BK Stulli |
|
|
|
|
|
#2 |
|
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
|
Try this
Sub Macro1() ' ' Macro1 Macro ' Macro recorded 5/25/2002 by Lawrence Shuler ' ' Range("B1").Select Selection.Copy Range("A1").Select Selection.End(xlDown).Select ActiveCell.Offset(1, 0).Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False End Sub |
|
|
|
|
|
#3 |
|
Join Date: Apr 2002
Location: iceland
Posts: 124
|
Thanks ElGringo, it worked great!
|
|
|
|
|
|
#4 | |
|
Join Date: Mar 2002
Location: England, UK.
Posts: 526
|
Quote:
Sub Macro1() Range("B1").Copy Range("A1").End(xlDown).Offset(1, 0).PasteSpecial xlPasteValues End Sub is the same macro, but tidied up, is now easier to look at and debug. Probably runs quicker too. RET79 |
|
|
|
|
|
|
#5 |
|
Join Date: Mar 2002
Location: England, UK.
Posts: 526
|
or even the one liner:
Sub Macro1() Range("B1").Copy Range("A1").End(xlDown).Offset(1, 0) End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|