VBA select cells to the right

Chenboy2

New Member
Joined
Sep 25, 2005
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Hi, i am trying to get the code that will select three cells across, including the active cell based on where the active cell is, insert new cells under the three cells, clearing the contents, but maintaining the formatting or just insert a new row, keeping the formatting. I don't have any other data on the rest of that row.

Like for example, I have some data already in columns A, B, and C and I'm in the active cell is A2 and I want to insert a new row or blank cells under A2, B2 and C2, but retain the formatting

Thanks!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
How about
Code:
    ActiveCell.Offset(1).EntireRow.Insert
 
Upvote 0
Thanks, what about a fill down on the cell? I want the VBA to be able to work on the column only.
 
Upvote 0
You originally said
insert new cells under the three cells, clearing the contents, but maintaining the formatting or just insert a new row, keeping the formatting.
The code I supplied inserts a new row under the active cell & maintains the formatting.
Is that not what you're after?
 
Upvote 0
I know, I was debating between whether to confine it to just the three columns and not the entire row. I forgot that I wanted to fill down the third column's cell. Sorry, it was around 3am when I posted this.
 
Upvote 0
I have a formula I want to fill down in the third column when I insert the new row. Originally I wanted to do a copy and insert cells below and then clear any data, at the same time let the formula fill down as well.
 
Upvote 0
Fair enough
Code:
Sub macro1()
     ActiveCell.Offset(1).EntireRow.Insert
     Range("C" & ActiveCell.Row).Resize(2).FillDown
End Sub
Sub Macro2()
     ActiveCell.Offset(1).Resize(, 3).Insert
     Range("C" & ActiveCell.Row).Resize(2).FillDown
End Sub
2 options, macro1 inserts a complete row, whilst macro2 inserts 3 cells
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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