Hi guys,
I have almost no experience with macros in Excel so I hope you'll be able to help me out.
I have an Excel file and what I want to do is look through column A until I come to a null column (or the value is 0) and delete every row after that. This works and clears all the data past 5000 but the problem I am having is if there are 5000 rows, there is data to row 17,000 that might just be " #ref" or formatted with color. So I want my code to completely remove anything after that first null so that when I import the data into Access I don't get all these null columns. The code I am using is as follows:
************************************************
For x = 1 To 65536
c1 = ActiveSheet.Cells(x, 1)
If Trim(c1) = "" Or c1 = "0" Then
ActiveSheet.Cells(x, 1).Select
lastrow = x
Application.Rows.EntireRow.Delete
GoTo delete_finished
End If
Next
delete_finished:
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.EntireRow.Delete
*************************************************
I appreciate any help, thank you.
Mike
I have almost no experience with macros in Excel so I hope you'll be able to help me out.
I have an Excel file and what I want to do is look through column A until I come to a null column (or the value is 0) and delete every row after that. This works and clears all the data past 5000 but the problem I am having is if there are 5000 rows, there is data to row 17,000 that might just be " #ref" or formatted with color. So I want my code to completely remove anything after that first null so that when I import the data into Access I don't get all these null columns. The code I am using is as follows:
************************************************
For x = 1 To 65536
c1 = ActiveSheet.Cells(x, 1)
If Trim(c1) = "" Or c1 = "0" Then
ActiveSheet.Cells(x, 1).Select
lastrow = x
Application.Rows.EntireRow.Delete
GoTo delete_finished
End If
Next
delete_finished:
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.EntireRow.Delete
*************************************************
I appreciate any help, thank you.
Mike