View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Symbiosis Symbiosis is offline
external usenet poster
 
Posts: 5
Default VBA Code to Delete Part of Row with Data

Hi..

If I understand you correctly Current period is entered in column H and the
data in Column J to M.

then the following should work, but can be easily amended.

Sub currentperiod()

Dim count As Integer

count = 2 ' Set this to the row number you want to start from

Do Until Cells(count, 8) = "" ' 8 indicates the column number
If Cells(count, 8) = "Current Period" Then
Range(Cells(count, 10), Cells(count, 14)).Select
Selection.ClearContents
Range(Cells(count + 1, 10), Cells(count + 1, 14)).Select
Selection.Copy
Cells(count, 10).Select
ActiveSheet.Paste
Range(Cells(count + 1, 10), Cells(count + 1, 14)).EntireRow.Delete
count = count + 1
Else
count = count + 1
End If
Loop

End Sub

Regards

Mick


"manfareed" wrote in message
...
Hi,
I need a macro to delete part of a row eg. column H to Column M and in its
place copy data into these columns from the row directly below it. Once
done
the row below should be "deleted". [please see below]
The Data is arranged as follows :

Cash Received

Consultant 1 Current Period 1 2 3 4
Quarter To Date 1 2 3 4

Consultant 2 Current Period 1 2 3 4
Quarter To Date 1 2 3 4
And so on ...

I would need to delete from "Current Period" in Column H to Column M in
all
rows which have "Current Period"
In its place I would need to copy "Quarter To Date" from the line below
plus
data in Columns J to M.

Once Done the line with originally with "Quarter to Date" needs to be
deleted so that everything moves up 1 row.