Checking if a cell is blank

P5X

New Member
Joined
Feb 16, 2002
Messages
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.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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
 
Upvote 0
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
 
Upvote 0
On 2002-02-17 10:10, P5X wrote:
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
Something like this:

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.
 
Upvote 0
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 :)
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,239
Members
448,951
Latest member
jennlynn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top