![]() |
![]() |
|
|||||||
| 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 |
|
New Member
Join Date: Feb 2002
Posts: 18
|
I want to paste data into a cell but I only want to do it if the selected cell is blank, if it isn't then the data should be posted in the next blank cell in the column.
Any ideas on how to do this would be appreciated. |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Richland, Washington
Posts: 91
|
p5x
If you're adding information to a given column, say Column A, then the code below would find the next blank cell in column A, and, in this case, paste the contents of range C8 there. Sub pleasepaste() [C8].Copy [A65536].End(xlUp).Offset(1, 0).PasteSpecial End Sub Tom |
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Posts: 18
|
Thanks Tom, that worked great.
I only want about 40 cells that allow data to be input into, how do you get a message box to pop up once the limit has been reached? thanks |
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Winnipeg
Posts: 2,330
|
Quote:
If Range("A65536").End(xlDown).Offset(1, 0).Row > 40 Then Exit Sub This will exit the sub if the row number is greater than 40. You can change the number to suit your purposes.
__________________
Barrie Davidson "You're only given a little spark of madness. You mustn't lose it." - Robin Williams |
|
|
|
|
|
|
#5 |
|
New Member
Join Date: Feb 2002
Posts: 18
|
perhaps you misunderstood, I have got the limit set to 40 by modifying Tom's statement:
[A40].End(xlUp).Offset(1, 0).PasteSpecial What I want now is an error message to come up once the limit has been reached. ps-i'm not too good with excel as you've probably figured so if you're statement did a similar thing then sorry |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Richland, Washington
Posts: 91
|
Following up on Barrie's suggestion...
If [A65536].End(xlup).Offset(1, 0).Row > 40 Then MsgBox "Sorry...no more room" Exit Sub else [A65536].End(xlUp).Offset(1, 0).PasteSpecial end if [ This Message was edited by: Tom Morales on 2002-02-17 16:03 ] [ This Message was edited by: Tom Morales on 2002-02-17 16:07 ] |
|
|
|
|
|
#7 |
|
Guest
Posts: n/a
|
Barrie and Tom wrote :-
If Range("A65536").End(xlDown).Offset(1, 0).Row > 40 This should read :- If Range("A65536").End(xlUp).Offset(1, 0).Row > 40 |
|
|
|
#8 |
|
Board Regular
Join Date: Feb 2002
Location: Richland, Washington
Posts: 91
|
Yeah, I copied it, and then realized the error. Thx.
Tom |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|