VBA/formula help

RattlingCarp3048

Board Regular
Joined
Jan 12, 2022
Messages
166
Office Version
  1. 365
Platform
  1. Windows
I have this spreadsheet that just keeps on circling back with problems, hopefully you guys can help once again....

It is updated with new data multiple times throughout the day so the last row is ever changing. the data is in A-Q with formulas going into R-X. Placement of the formulas in V-X is the issue.

When the spreadsheet is updated i need to find the next available row in column V-X and place the formulas. How can i find the next available row in V-X?

if I use lastrow = Cells(Rows.Count, "V").End(xlUp).Offset (1).Row is shows the next row = 9001 but its not, in this update the next cell in column V-X is 8993

1646844095075.png


1646844174383.png
1646844204528.png
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I suspect V9000 is not empty. Maybe it contains a formula that returns "" or has an invisible character.

Try msgbox len([V9000].formula)

if you get a non-zero, it's not empty
 
Upvote 0
I suspect V9000 is not empty. Maybe it contains a formula that returns "" or has an invisible character.

Try msgbox len([V9000].formula)

if you get a non-zero, it's not empty
correct, there was a formula in V-X 9000 that resulted in "" but i copy/pasted special values to remove the formula and leave the cells blank. Ive tried multiple approaches to this and everytime i think its solved i catch an error i didnt see before.

I can leave the formulas the cells, thats not an issue at all. The ultimate goal is when the new data is added in A-Q then find the last row in R-X and fill the formulas down to the last row. thats it. Any ideas how i can do that?
 
Upvote 0
I suspect V9000 is not empty. Maybe it contains a formula that returns "" or has an invisible character.

Try msgbox len([V9000].formula)

if you get a non-zero, it's not empty
kind of an example of the code i have at the moment

lastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("V2:X" & lastRow).SpecialCells(xlCellTypeBlanks).Formula = Range("V2:X2").Formula

when it pulls the formulas down its supposed to copy the formula from V2-X2 and fill down to all the blank cells. Problem is in V9000 the formula should be vlookup(U9000,'Yesterday's Report' U:V,2,0) but instead it is putting vlookup(U3,'Yesterday's Report' U:V,2,0)
 
Upvote 0
Range("V2:X" & lastRow).SpecialCells(xlCellTypeBlanks).FormulaR1C1 = Range("V2:X2").FormulaR1C1
 
Upvote 0
Range("V2:X" & lastRow).SpecialCells(xlCellTypeBlanks).FormulaR1C1 = Range("V2:X2").FormulaR1C1
Hi JGordon, sorry for the delayed reply. We've been testing out your suggestion over the past week as well as attempting to modify for solutions but are still getting similar errors as before. Initially the Vlookup was starting the count over at U2 when pulling the formulas down. now with the updated code you provided the count is skipping rows when pulling the formulas down, it appears to be at an exponential rate. Any thoughts? Its definitely closer than we had before but still no true fix.

1647876718599.png


1647876726002.png


1647876733288.png
 
Upvote 0
'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

Forum statistics

Threads
1,214,983
Messages
6,122,595
Members
449,089
Latest member
Motoracer88

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