Chenboy2

New Member
Joined
Sep 25, 2005
Messages
34
Office Version
  1. 365
Platform
  1. Windows
I'm trying to create a fill down macro for the range D4:D5028

Here's the code I have so far:

I got most of this online.

Thanks.


Sub FixParent()
'
' FixParent Macro
'


'
Dim lastrow As Long


lastrow = Range("D4:D5028").End(xlUp).Row
'ActiveCell.FormulaR1C1


' Selection.AutoFill Destination:=Range("Table1[Parent]")
Selection.AutoFill Destination:=Range("D4:D5028" & lastrow)
Range("D4:D5028").Select
'Range("D4").Select
'Selection.End(xlDown).Select
'ActiveCell.Offset(0, 1).Select
'Range(Selection, Selection.End(xlUp)).Select
'Selection.FillDown


End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
thats quite a mess although only 2 lines of code are actually working, what are you trying to do, put the formula in D4 to D5028?

What is the formula?
 
Upvote 0
Yeah, that's the only cells I want to fill down. It's a vlookup formula that keeps getting messed up. I'm entering data in the table and it doesn't reference the right corresponding cells next to it. If you need the formula I'm using, I'll paste it.

The code doesn't really work.
 
Upvote 0
yes post the formula and I am sure either myself or someone else will be glad to help,

Is the vlookup, lookiing at the cell to the left of it or something?
 
Upvote 0
=VLOOKUP(Actual!$C151,$CW$4:$CX$9,2)


CW CX
1Income
2Expense
3Other Income
4Refund
5Reimbursement
6Savings

<colgroup><col span="2"></colgroup><tbody>
</tbody>

I hope this explains it.
 
Upvote 0
That the value in CW matches with CX. What happens is that the value in CX gets shifted around. The only solution I found was to fill down in D4 down to D5028. If I could automate it with a macro, it would save time.
 
Upvote 0
something like this.

Code:
Sub addit()


    Range("D5:D5028") = Range("D4").Formula
    
End Sub
 
Upvote 0
I'm confused, do I add that code to the existing code I have or do I create a new macro? How does that line up the values of CW and CX in columns C and D?

Let me explain, I enter a number from 1 through 6 in column C and the corresponding value (Income, Expense, etc.) is populated in D. For some reason the same row in C does not match in row D so the cell reference does not match and the information is wrong, so D5 will reference the value of C3 in the vlookup formula or any other cell, not C5.
 
Last edited:
Upvote 0
Let me explain a little more about what s going on:

It should be like this:

CD
41Income
52Expenses
6
2Expense
74Refund
82Expense

<tbody>
</tbody>










But for some reason, it sometimes becomes like this:

CD
41Expense
52Income
62Expense
74Refund
82Income

<tbody>
</tbody>










The corresponding row in C doesn't match with row D. A fill down of the VLOOKUP formula will quickly fix the problem, but I want to write a macro so I can quickly do that.

Does that make sense?
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,266
Members
448,558
Latest member
aivin

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