Copy down Macro

aerodynamix

New Member
Joined
Sep 27, 2002
Messages
1
Have a macro to fill blank cells with data from above:

Public Sub CopyDown()
LastRow = Range("A65536").End(xlUp).Row
For i = 1 To LastRow
If Range("A" & i).Value = "" Then
Range("A" & i - 1 & ":CB" & i - 1).Copy Destination:=Range("A" & i)
End if
Next i
End Sub

The problem lies when the cell contains something other than a date or integer. If for example the cell contains "=====" I want to replace it with the date or integer above.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

rikrak

Active Member
Joined
Aug 21, 2002
Messages
255
On 2002-09-28 13:07, aerodynamix wrote:
Have a macro to fill blank cells with data from above:

Public Sub CopyDown()
LastRow = Range("A65536").End(xlUp).Row
For i = 1 To LastRow
If Range("A" & i).Value = "" Then
Range("A" & i - 1 & ":CB" & i - 1).Copy Destination:=Range("A" & i)
End if
Next i
End Sub

The problem lies when the cell contains something other than a date or integer. If for example the cell contains "=====" I want to replace it with the date or integer above.

Hi,

Try this IF-statement:
If Application.WorksheetFunction.IsText(Range("A" & i)) Then
 

Forum statistics

Threads
1,144,358
Messages
5,723,891
Members
422,524
Latest member
wirkkarn

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
Top