Macro to select the 20 rows below the currently selected cell

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
194
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I have a macro that selects the cell in column A which contains the text "Freight Summary". "Freight Summary" is always in column A but can be in any row. I need to continue this macro by selecting the 20 rows below the cell containing "Freight Summary", copy those rows over to column B

Thanks,
B
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
One simple way:
VBA Code:
    Range(ActiveCell, ActiveCell.Offset(20, 1)).Select
 
Upvote 0
One simple way:
VBA Code:
    Range(ActiveCell, ActiveCell.Offset(20, 1)).Select
Joe4,
I didn't explain it effectively. Your addition selects what was required, I edited the code to select 6 columns which is what was needed and works correctly. Also what I need is to bump that entire selection(column A: G) right one column to column B:H
 
Upvote 0
Joe4,
I didn't explain it effectively. Your addition selects what was required, I edited the code to select 6 columns which is what was needed and works correctly. Also what I need is to bump that entire selection(column A: G) right one column to column B:H
Still not being too clear on what exactly you need.

Let's come at this from a different angle:
If the ActiveCell is cell A4, what range exactly do you want to select (tell me the exact rangel address).
 
Upvote 0
@Buns1976 is there any data to right of the data being moved (i.e. Column H and onwards)?
 
Upvote 0
Still not being too clear on what exactly you need.

Let's come at this from a different angle:
If the ActiveCell is cell A4, what range exactly do you want to select (tell me the exact rangel address
I attached 3 pics below. Pic 1 is the original state. Pic 2 is after the macro is run. Pic 3 is the desired state where the selection is mover 1 column to the right.
 

Attachments

  • 1.png
    1.png
    43.1 KB · Views: 3
  • 2.png
    2.png
    45.1 KB · Views: 3
  • 3.png
    3.png
    46.6 KB · Views: 3
Upvote 0
Then you should be able to just do an insert
VBA Code:
Sub Buns()
ActiveCell.Offset(1).Resize(20).Insert
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,102
Messages
6,123,099
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top