VBA Code- finding #Spill and moving the formula to the next column

stromnoexcel

New Member
Joined
Dec 4, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I'm not sure if it's even possible, but I need help in the following:
1701816668852.png

so far, I made a made to insert rows, by the value of D minus 1, each time column D is >1. The macro is working from bottom to top since its trickier for the macro to function if the last row keeps changing as its going top to bottom. Columns A-D are searched by blanks and then are pasted with values below it. (Hope that makes sense)

"Sub InsertingRows_FillingBlanksWBelows()
'
' InsertingRows_FillingBlanksWBelows Macro
'
'

Dim v2 As Worksheet
Dim LastRow As Long 'Integer
Dim lngIdx As Long
Dim a As Variant
Dim J As Long

'Loop through the data range BACKWARDS, tracking each case where a row will need to be inserted
'Loop through the row numbers in the collection, which is in REVERSE order (adding rows will change the row numbers in the range,
'making forward looping hard)

Set v2 = Worksheets("v2") 'assign worksheet to variable v2

With v2
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Row 'determine last row

For lngIdx = LastRow To 2 Step -1 'step thru backwards
a = .Cells(lngIdx, 4).Value
If IsNumeric(a) And a > 1 Then 'except 1
Application.ScreenUpdating = False 'turn off screen updating

'Insert new rows
For J = 1 To (a - 1)
.Rows(lngIdx).Insert Shift:=xlUp
Next J
Application.ScreenUpdating = True 'turn on screen updating
End If
Next lngIdx
End With

Range("A1:D36824").Select 'Range for D would have to get updated each refresh?
Selection.SpecialCells(xlCellTypeBlanks).Select 'finds all blanks and ='s then to one below
Application.CutCopyMode = False
Selection.FormulaR1C1 = "=R[1]C" '=copying below
'A-D is all filled in, now:

'1. FIND #Spills and move it over to the column next to it
'-allows the filter formula to spill down without being blocked
' this would mean having possibly 2 buttons. 1st one inserts the rows for caontiners>1 +fill in blanks aka macro above
' Person refreshing would then have to add the containers (alt+h+v+v) manually
' 2nd would be bring down the remaining formulas

End Sub"



Now, I'm having trouble filling the blank cells since all YouTube videos show how to fill from the row above, instead of the row below.

Any help on how to move forward is appreciated. Again my thinking is in the last paragraph comment, but if there's a way to combine everything into one macro that would be great.

TLDR: How can I get the formulas below blank cells to be switch spots and be in the blank cells? This will allow the second name to be visible and remove the #Spill. The goal of the sheet in general is to duplicate the info row in columns A-D and for row G to not have spills so the 2nd name can be seen.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,224,748
Messages
6,180,721
Members
452,995
Latest member
isldboy

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