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
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,336
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
13,336
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
13,336
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
13,336
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:

Watch MrExcel Video

Forum statistics

Threads
1,109,322
Messages
5,528,007
Members
409,798
Latest member
Snake68

This Week's Hot Topics

Top