I have a problem with my VBA code in Excel. My table consists of a few columns with different lengths. In front of every of these columns I want to show the actual ID of the block(not the problem). The thing is that the actual ID only occurs in the first row of the block so there is a certain amount of empty cells under every block ID.
I found a code with which I can fill these empty cells with the actual block ID:
Sub Leere_auffuellen()
With Worksheets(3).Range("A5:A1000")
If Application.WorksheetFunction.CountBlank(Intersect(.Cells, .Parent.UsedRange)) > 0 Then
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
.Value = .Value
End If
End Sub
This works for the longest column. My problem is that I want to do that for the shorter columns, too. If I use the code above, it fills the rows with IDs until the length of the longest row is reached. How can I adjust the code so that it refers to the column I want it to?
I hope you guys understand what I want