VBA Error, But Can't Fix It

SonicBoomGolf

Active Member
Joined
Aug 7, 2004
Messages
325
I am having a problem with the following code.

Public Sub OrderSummary()

botrw = 55
' Inserts a New Column in Column A
With Range("a:a").Select
Selection.Insert shift:=xlToRight
End With
Do
toprw = Range("m" & botrw).End(xlDown).Row
botrw = Range("m" & toprw).End(xlDown).Row
Cells(toprw - 1, 2).Cut
Range(Cells(toprow, 2), Cells(botrw - 2, 2)).Paste
Loop Until botrw = Cells(65536, 2).End(xlUp).Row
End Sub

I get a Run-Time 1004 Error when it comes to this portion of the code:
Range(Cells(toprow, 2), Cells(botrw - 2, 2)).Paste

I don't understand what is wrong with this. Any ideas?
 
The following code is my first stab at doing what I want and it is kinda doing what I want it to. Using my previous post as an illustration, the macro will delete the number 727 in cell B4, but then the blank cell from B5 is moved up to B4, and since the loop moves onto the next cell, the blank cell now in cell B4 remains. Below is my code.

finalrow = Cells(65536, 2).End(xlUp).Row
For i = 2 To finalrow
If Cells(i, 2).NumberFormat = "m/d/yyyy" Then
Else
Rows(i, 2).Delete
End If
Next i

How can I get the code to delete everything that is not in a date format in Column B??
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,215,945
Messages
6,127,844
Members
449,411
Latest member
adunn_23

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