Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Check to see if cell is blank

I want my macro to first check & see if A9 is blank. If it is I want to
paste copied data in A9, if it is not blank I want to proceed with finding
the 1st blank cell in column A and pasting there (which is how the macro is
set up)


Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(rowOffset:=1).Activate

ActiveSheet.Paste
Columns("D:D").EntireColumn.AutoFit

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Check to see if cell is blank

Try:

Sub Macro1()
Dim i As Integer
i = Range("A65536").End(xlUp).Row + 1

If Range("A9") = "" Then
Range("A9").PasteSpecial xlPasteAll
Else
i = Range("A65536").End(xlUp).Row + 1
Cells(i, 1).PasteSpecial xlPasteAll
End If

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Check to see if cell is blank

Sorry, I assigned a value to i twice, you can remove one:

Sub Macro1()
Dim i As Integer

If Range("A9") = "" Then
* * Range("A9").PasteSpecial xlPasteAll
* * * * Else
* * * * i = Range("A65536").End(xlUp).Row + 1
* * * * Cells(i, 1).PasteSpecial xlPasteAll
End If

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Check to see if cell is blank

One way,

Sub test()
Dim rCopy As Range, rDest As Range

Set rCopy = ActiveSheet.Range("A1:D1")
Set rDest = ActiveSheet.Range("A24")

If Len(rDest) Then
If Len(rDest.Offset(1, 0)) Then
Set rDest = rDest.End(xlDown).Offset(1, 0)
Else
Set rDest = rDest.Offset(1, 0)
End If
End If

rCopy.Copy rDest

End Sub

Note no need to select

Regards,
Peter T

"Munchkin" wrote in message
...
I want my macro to first check & see if A9 is blank. If it is I want to
paste copied data in A9, if it is not blank I want to proceed with finding
the 1st blank cell in column A and pasting there (which is how the macro
is
set up)


Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(rowOffset:=1).Activate

ActiveSheet.Paste
Columns("D:D").EntireColumn.AutoFit



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Check to see if cell is blank

typo, change

Set rDest = ActiveSheet.Range("A24")
to
Set rDest = ActiveSheet.Range("A9")

Peter T


"Peter T" <peter_t@discussions wrote in message
...
One way,

Sub test()
Dim rCopy As Range, rDest As Range

Set rCopy = ActiveSheet.Range("A1:D1")
Set rDest = ActiveSheet.Range("A24")

If Len(rDest) Then
If Len(rDest.Offset(1, 0)) Then
Set rDest = rDest.End(xlDown).Offset(1, 0)
Else
Set rDest = rDest.Offset(1, 0)
End If
End If

rCopy.Copy rDest

End Sub

Note no need to select

Regards,
Peter T

"Munchkin" wrote in message
...
I want my macro to first check & see if A9 is blank. If it is I want to
paste copied data in A9, if it is not blank I want to proceed with
finding
the 1st blank cell in column A and pasting there (which is how the macro
is
set up)


Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(rowOffset:=1).Activate

ActiveSheet.Paste
Columns("D:D").EntireColumn.AutoFit







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Check to see if cell is blank

1. Post ALL of your code for comments
2. Is there data in col a below where you think the next blank cell should
be or will there just be blanks below.

sub copytonar()'copies to last available row in col A
lr=cells(rows.count,1).end(xlup).row +1
if len(application.trim(range("a9")))<1 then lr =9
range("c2:c22").copy cells(lr,1)
end sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Munchkin" wrote in message
...
I want my macro to first check & see if A9 is blank. If it is I want to
paste copied data in A9, if it is not blank I want to proceed with finding
the 1st blank cell in column A and pasting there (which is how the macro
is
set up)


Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(rowOffset:=1).Activate

ActiveSheet.Paste
Columns("D:D").EntireColumn.AutoFit


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
Conditional formatting - check for blank cell Eric_NY Excel Discussion (Misc queries) 3 August 18th 09 05:08 PM
Want to check if cell is blank before running macro Munchkin Excel Programming 5 June 3rd 09 11:59 PM
check to see if a cell is blank if not populate adjacent cell wit. Frusterated Excel Discussion (Misc queries) 6 September 14th 07 10:55 PM
Need macro to check if cell is not blank & previous cell is blank, copy information from row above & paste JenIT Excel Programming 4 April 12th 07 08:56 PM
How to check if a cell is blank and, if so, apply a formula Arnold[_3_] Excel Programming 1 December 27th 06 09:15 PM


All times are GMT +1. The time now is 05:12 AM.

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"