Macro to fill column

Xirom431

Board Regular
Joined
Dec 2, 2010
Messages
94
Hi,

I need help with a macro to fill column with value that will skip cell. For example, I need to fill column with value X but skip every other row or every 5 range from A3 to A1000. Thanks for the help in advance.

X or X or X
X
X

X X
X
X X
 

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.

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,468
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
I'm not sure either from your description or your diagram exactly what you want but perhaps the code below will get you started and you can post back with whatever you need to act differently.

Code:
Sub xxx()
    Dim x As Long, i As String

    i = InputBox("Please enter value to insert")

    For x = 3 To 1000 Step 4
        Cells(x, "A").Resize(3, 1).Value = i
    Next

End Sub
 

Xirom431

Board Regular
Joined
Dec 2, 2010
Messages
94
I have a formula in Cell A3. I would like to copy the same formula down the column but skip every other cell and range from A3:A1000

X
Skip
X
Skip
X


or this scenario

X
X
Skip
Skip
X
X


or

X
X
X
X
Skip
Skip
Skip
Skip
X
X
X
X

Basically it looks like a power of 2.
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,468
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
You will have to adjust the 1000 to exactly what you want in each

Code:
Sub xxx()
    Dim x As Long, i As String

    

    For x = 3 To 1000 Step 2
    Range("a3").Copy Cells(x, "A")
    Next

End Sub
Code:
Sub xxx2()
    Dim x As Long, i As String

    

    For x = 3 To 1000 Step 4
    Range("a3").Copy Cells(x, "A").Resize(2, 1)
    Next

End Sub
Code:
Sub xxx3()
Dim x As Long, i As String

    

    For x = 3 To 1000 Step 8
    Range("a3").Copy Cells(x, "A").Resize(4, 1)
    Next

End Sub
 

Xirom431

Board Regular
Joined
Dec 2, 2010
Messages
94

ADVERTISEMENT

Something is wrong. The macro is working with regular number only. I have formula in Cell V3 and it will indent to the left and run over to the previous column
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,468
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Sorry, no idea it works fine with formulas for me. I put a formula in A3, ran the first macro and got the results you see in the formula box in the image below

Excel Workbook
ABCD
35715
418
55924
618
76917
826
95726
1012
115819
1213
137226
1421
156725
1621
176321
1823
194019
2010
215111
Sheet1
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,468
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Something is wrong. The macro is working with regular number only. I have formula in Cell V3 and it will indent to the left and run over to the previous column

Please show your formula and an example of your data and how are your cells formatted?

+ what shows in your formula bar when you click a cell (both V3 and one of the other cells)
 
Last edited:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,299
Messages
5,836,484
Members
430,435
Latest member
Benforest1

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
Top