Hi,
I created this vba code (from scratch, I'm very proud of it). The code is assigned to a text box and when it's clicked the macro starts running. It's a pretty basic copy/paste so far but I want to add a few lines that does the following after the marked line:
I want the macro to do a cells(1,lastrow+1).select and change the range name to whatever is in cells(1,lastrow+1) and substitute any spaces " " with "_". Then I want it to select the entire columns(lastrow+1) and change the name to whatever is in cells(1,lastrow+1) and add a "Col" at the end of the name.
This is probably very easy to code, but I can't figure it out.
Sub LäggTillNyProdukt()
Dim LastColumn As Integer
Dim LastRow As Integer
'Lägg till ny uppdateringsknapp
Sheets("uppdatera").Select
'Hittar sista raden och ger den ett nummer
LastRow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
Rows(LastRow).Copy
Rows(LastRow + 2).Select
ActiveSheet.Paste
Range("B3").Copy
Cells(LastRow + 2, 1).Select
ActiveSheet.Paste
'Lägg till information för lista
Range("B3").Copy
Sheets("Lista").Select
'Hittar sista raden och ger den ett nummer
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(LastRow + 1, 1).Select
ActiveSheet.Paste
Cells(LastRow + 1, 1).Copy
Cells(1, LastRow + 1).Select
ActiveSheet.Paste
'ADD NEW LINES HERE
'Gå tillbaka till Uppdatering
Sheets("Uppdatera").Select
Range("B3").Select
Application.CutCopyMode = False
End Sub
Bookmarks