Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I need to fix my macro. It is giving me an error message.
The macro is supposed to do this: if the value in column B is less than zero, the macro should cut the entire row and paste it into the last available row. It should check rows 1- 199. Thank you in advance Sub CutandPaste() Dim i As Integer LRow = Range("A1").End(xlUp).Row For i = 9 To 199 If Cells(i, 2) 0 Then EntireRow.Cut Destination:=Range("a1:a" & LRow).PasteSpecial End If Next i End Sub |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Un tested but should do it. Lots of errors but good try
Sub CutandPaste() Dim i As Integer 'LRow = Range("A1").End(xlUp).Row LRow = cells(rows.count,"a").end(xlup).row+1 For i = 9 To lr If Cells(i, 2)< 0 Then rows(i).Cut Destination:=cells(lrow,"a") End If Next i End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "David T" wrote in message ... I need to fix my macro. It is giving me an error message. The macro is supposed to do this: if the value in column B is less than zero, the macro should cut the entire row and paste it into the last available row. It should check rows 1- 199. Thank you in advance Sub CutandPaste() Dim i As Integer LRow = Range("A1").End(xlUp).Row For i = 9 To 199 If Cells(i, 2) 0 Then EntireRow.Cut Destination:=Range("a1:a" & LRow).PasteSpecial End If Next i End Sub |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
The macro was pretty close. The only thing is that it keep on pasting all
the cut cells over each other. I need the the rows to be pasted one below the next. Thanks for your help! "Don Guillett" wrote: Un tested but should do it. Lots of errors but good try Sub CutandPaste() Dim i As Integer 'LRow = Range("A1").End(xlUp).Row LRow = cells(rows.count,"a").end(xlup).row+1 For i = 9 To lr If Cells(i, 2)< 0 Then rows(i).Cut Destination:=cells(lrow,"a") End If Next i End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "David T" wrote in message ... I need to fix my macro. It is giving me an error message. The macro is supposed to do this: if the value in column B is less than zero, the macro should cut the entire row and paste it into the last available row. It should check rows 1- 199. Thank you in advance Sub CutandPaste() Dim i As Integer LRow = Range("A1").End(xlUp).Row For i = 9 To 199 If Cells(i, 2) 0 Then EntireRow.Cut Destination:=Range("a1:a" & LRow).PasteSpecial End If Next i End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
PLEASE help with cut/paste macro | Excel Discussion (Misc queries) | |||
cut and paste macro | Excel Worksheet Functions | |||
Macro needed to Paste Values and prevent Macro operation | Excel Discussion (Misc queries) | |||
Macro needed to Paste Values and prevent Macro operation | Excel Discussion (Misc queries) | |||
Cut&Paste Macro | Excel Worksheet Functions |