ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check to see if cell is blank (https://www.excelbanter.com/excel-programming/439180-check-see-if-cell-blank.html)

munchkin

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


GTVT06

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

GTVT06

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


Peter T

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




Peter T

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






Don Guillett[_2_]

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




All times are GMT +1. The time now is 07:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com