Ongoing VBA code issue

Status
Not open for further replies.

RattlingCarp3048

Board Regular
Joined
Jan 12, 2022
Messages
166
Office Version
  1. 365
Platform
  1. Windows
Ive posted a lot about this same issue and its still ongoing. Multiple different approaches have been taken and tried. Each approach has worked for a limited amount of time but after a few days it come back to the same issue.

The issue being the formulas are not autofilling sequentially, during the autofill the rows are skipping numbers. EX: V11636 = VLOOKUP(U11638,'Yesterday''s Report'!U:V,2,0) I need to find the last row of formulas in V-Y and fill down to the last row of data in U. I keep getting closer and closer with each suggestion but still have the issue.

'Find last row in U
lastrow = Cells(Rows.Count, "U").End(xlUp).Row
'Find last row of formulas in V-Y
Range("V1").Select
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.copy
'AutoFill last row of formula V-Y and last row U.
Selection.AutoFill Destination:=Range(ActiveCell.Address & lastrow) <--- this row debugs
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
In columns V-Y, what is the FIRST row with formulas?
Is it row 1 or row 2?
 
Upvote 0
If it is row 2, I think this is all you reaally need:
VBA Code:
    Dim lastrow As Long

'   Find last row in U
    lastrow = Cells(Rows.Count, "U").End(xlUp).Row
    
'   Copy formulas from row 2 down to last row
    Range("V2:Y2").Copy Range("V3:V" & lastrow)
 
Upvote 0
In columns V-Y, what is the FIRST row with formulas?
Is it row 1 or row 2?
Its row 2. This is what i had originally...

'Fill down formlas in Column V-X
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Range("V2:Y" & lastrow).SpecialCells(xlCellTypeBlanks).Formula = Range("V2:Y2").Formula

then this...
'Fill down formlas in Column V-X
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Range("V2:Y" & lastrow).SpecialCells(xlCellTypeBlanks).FormulaR1C1 = Range("V2:Y2").FormulaR1C1

in both cases i get a lot of #N/A's when the formula populates which there shouldnt be any at all.... AND the rows are not pulling down sequentially in the formula AND sometimes the formulas will over-write data despite the SpecialCells(xlCellTypeBlanks) being coded. the N/A's and over-writing seem to be at random and inconsistent. i have to re-run the macro 2-3 times before it stops, and sometimes i just end up fixing the issues manually.
 
Upvote 0
AND sometimes the formulas will over-write data despite the SpecialCells(xlCellTypeBlanks) being coded. the N/A's and over-writing seem to be at random and inconsistent.
This is an extremely important detail that you did not include in your original question or code posted.
Why didn't you tell us that? That changes things SIGNIFICANTLY.

Since this is a continuation/duplicate of this thread here: VBA/formula help, I am going to lock this one and ask that you continue in your original thread, as per rule 12 here: Message Board Rules

If you do not receive a reply after 24 hours, you can "bump" your original thread by replying back to it.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,948
Messages
6,122,420
Members
449,083
Latest member
Ava19

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