Hello, I came across an issue whilst stacking multiple (specific) columns in excel. I have 5 columns that needs to be stacked up to last non empty cell. The data changes in every column occasionally, so range of each column might be different. There I do need to include Range.End(xlUp) as well... Looking at "Stack multiple columns VBA code", I was able to gain some clarity, however, I'm met with another obstacle.
Issue: While the code that I referenced was helpful, and successful in transferring across data (names), it isn't the same for cells that contain formulas... I'd like to seek for help to the data that I'm stacking which contains formulas, and it's presented in a % format. Is there any way to copy, and paste the values (e.g 10%, 14%) into another column while excluding the formulas? I think it might be something along the lines of PasteSpecial Paste:=xlPasteValuesAndNumberFormats, but I cant seem to get the code right
Sub Test()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Dim Lastrowa As Long
For i = 1 To 5
Lastrow = Cells(Rows.Count, Choose(i, "C", "G", "K", "O", "R")).End(xlUp).Row + 1
If i = 1 Then
Lastrowa = 2
Else
Lastrowa = Cells(Rows.Count, "V").End(xlUp).Row 'mod
End If
Range(Cells(2, Choose(i, "C", "G", "K", "O", "R")), Cells(Lastrow, Choose(i, "C", "G", "K", "O", "R"))).Copy Cells(Lastrowa + 1, "V")
Next
Application.ScreenUpdating = True
End Sub
Issue: While the code that I referenced was helpful, and successful in transferring across data (names), it isn't the same for cells that contain formulas... I'd like to seek for help to the data that I'm stacking which contains formulas, and it's presented in a % format. Is there any way to copy, and paste the values (e.g 10%, 14%) into another column while excluding the formulas? I think it might be something along the lines of PasteSpecial Paste:=xlPasteValuesAndNumberFormats, but I cant seem to get the code right
Sub Test()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Dim Lastrowa As Long
For i = 1 To 5
Lastrow = Cells(Rows.Count, Choose(i, "C", "G", "K", "O", "R")).End(xlUp).Row + 1
If i = 1 Then
Lastrowa = 2
Else
Lastrowa = Cells(Rows.Count, "V").End(xlUp).Row 'mod
End If
Range(Cells(2, Choose(i, "C", "G", "K", "O", "R")), Cells(Lastrow, Choose(i, "C", "G", "K", "O", "R"))).Copy Cells(Lastrowa + 1, "V")
Next
Application.ScreenUpdating = True
End Sub