Thread: Script Help?
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John Williams[_4_] John Williams[_4_] is offline
external usenet poster
 
Posts: 12
Default Script Help?

couger77 wrote in message ...
Need help writing a simple script for the following excel file attached.

I am trying to figure out a way to delete cell C4 and then have it
shift the rows over to the left to lign up like the rest. This is just
a sample of over a thousand lines. Some have *, some don't. That is the
rub.


How about:

Sub Macro1()
Dim iRow, lastRow As Long
Dim rng

'Determine the last row

Worksheets("Sheet1").Select
Range("A1").Select
lastRow = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row

'For rows containing '*' in C column, replace the '*' with the 4
columns to the right

For iRow = 1 To lastRow
Set rng = Cells(iRow, "C")
If rng.Value = "*" Then
Set rng = Range(Cells(iRow, "D"), Cells(iRow, "G"))
rng.Select
Selection.Cut Destination:=Range(Cells(iRow, "C"),
Cells(iRow, "F"))
End If
Next

End Sub