Script Help?

C

couger77

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 i
shift the rows over to the left to lign up like the rest. This is jus
a sample of over a thousand lines. Some have *, some don't. That is th
rub.


Thanks in advance for any help!

Attachment filename: sample.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=50155
 
J

John Williams

couger77 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top