#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need Help



I am trying to accomplish the following in Excel:

Sub Correct_Rows()
if B2 = 16210 Then
Cut cells B2:V2
Move Up 1 Row
Move Over 4 Columns
Past cells
Delete Row 2
ElseIf B2 = "PO" Then
Delete Row 2
End If

Scroll thru rest of rows in Column B and repeat.

End Sub

The size of the worksheet will vary each time the macro is run, so it
must be dynamic. Column B will always be the column checked and the cut
and paste will always be "cut n, paste n-1, four columns over.

See? I have been trying desperately to build this and CANNOT figure out
how to use the debug (or any of the tools). I just assume that when it's
right, it will do what i need.

Any help is greatly appreciated!!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Need Help


You might try something like:
Sub Correct_Rows()
If Cells(2, 2) = 16210 Then
Dim MyRowNumber As Integer
Dim MyColumnNumber As Integer
MyRowNumber = 2
MyColumnNumber = 2
'cut cells in Range B2 to V2)
Range(Cells(MyRowNumber, MyColumnNumber), Cells(MyRowNumber,
MyColumnNumber + 20)).Cut
'Move up 1 row and move 4 columns to the right.
Cells(MyRowNumber - 1, MyColumnNumber + 4).Select
ActiveSheet.Paste
Rows(2).EntireRow.Delete

ElseIf Cells(2, 2) = "PO" Then
Rows(2).EntireRow.Delete
End If
End Sub

You can use the macro recorder as a very useful tool in writing the code.
Hope this helps.
Ron Dahl




"stephanie spomer" wrote in message
...


I am trying to accomplish the following in Excel:

Sub Correct_Rows()
if B2 = 16210 Then
Cut cells B2:V2
Move Up 1 Row
Move Over 4 Columns
Past cells
Delete Row 2
ElseIf B2 = "PO" Then
Delete Row 2
End If

Scroll thru rest of rows in Column B and repeat.

End Sub

The size of the worksheet will vary each time the macro is run, so it
must be dynamic. Column B will always be the column checked and the cut
and paste will always be "cut n, paste n-1, four columns over.

See? I have been trying desperately to build this and CANNOT figure out
how to use the debug (or any of the tools). I just assume that when it's
right, it will do what i need.

Any help is greatly appreciated!!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"