I had to define some variables and not really confident in that task but have
this working. Problem is it stops abruptly at row 4051. There are a total
of 4588 rows in the spreadsheet and will grow each week. No obvious reason
staring me in the face that it would stop but perhaps my variables aren't
correct? Like I said, not vb educated so I may have done something
incorrectly.
Public Sub Cut_Offset()
Dim y As Single
Dim x As Single
y = Excel.WorksheetFunction.CountA(Columns("B:B"))
For x = 1 To y
If Cells(x, 2).value = "Date" Then
If Cells(x, 3).value = "" Then
range(Cells(x + 1, 3).Address & ":" & Cells(x + 1, 15).Address).Cut
Cells(x, 3).Select
ActiveSheet.Paste
Application.CutCopyMode = False
' Rows(x + 1).Delete ' Delete Statement
End If
End If
Next
End Sub
"Thomas [PBD]" wrote:
> Jeremiah,
>
> What I meant was that once the cutting is placed into the correct line the
> line the data came from would be blank. Would you like it deleted. I wrote
> this quick macro here where you can remove the ' in front of the delete
> statement if you wish to use it.
>
> Public Sub Cut_Offset()
> y = Excel.WorksheetFunction.CountA(Columns("B:B"))
>
> For x = 1 To y
> If Cells(x, 2).Value = "Date" Then
> If Cells(x, 3).Value = "" Then
> Range(Cells(x + 1, 3).Address & ":" & Cells(x + 1, 15).Address).Cut
> Cells(x, 3).Select
> ActiveSheet.Paste
> Application.CutCopyMode = False
> ' Rows(x + 1).Delete ' Delete Statement
> End If
> End If
> Next
> End Sub
>
> This will count the number of rows that say "Date" in Column B, copy the row
> below it from C:O and place it the row above it. Optional delete blank row.
>
> --
> --Thomas [PBD]
> Working hard to make working easy.
> Answered your question? Click ''Yes'' below.
>
>
> "jeremiah" wrote:
>
> > Just blank, deleting will misalign the rest of the spreadsheet
> >
> > "Thomas [PBD]" wrote:
> >
> > > Jeremiah,
> > >
> > > Would you like the row that you are cutting from to be deleted once the
> > > process is completed (as it should be blank)?
> > >
> > > --
> > > --Thomas [PBD]
> > > Working hard to make working easy.
> > > Answered your question? Click ''Yes'' below.
> > >
> > >
> > > "jeremiah" wrote:
> > >
> > > > I am trying to figure out the following....If the value of column B = "Date"
> > > > and columns C:O are empty, cut and copy the values from columns C:O in the
> > > > row directly below. Example below, the numbers in the row need to line up
> > > > with Date. The file was an imported csv file so sometimes the rows line up
> > > > and other times they don't.
> > > >
> > > > Date
> > > > 493,352 102.98 4,791 30.88 58,072 1,881
> > > >
> > > >
|