Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Conditional formatting - check for blank cell | Excel Discussion (Misc queries) | |||
Want to check if cell is blank before running macro | Excel Programming | |||
check to see if a cell is blank if not populate adjacent cell wit. | Excel Discussion (Misc queries) | |||
Need macro to check if cell is not blank & previous cell is blank, copy information from row above & paste | Excel Programming | |||
How to check if a cell is blank and, if so, apply a formula | Excel Programming |