I believe this does what you are asking for.
Sub LäggTillNyProdukt()
Dim LastColumn As Integer
Dim LastRow As Integer
'Lägg till ny uppdateringsknapp
With Sheets("uppdatera")
'Hittar sista raden och ger den ett nummer
LastRow = .UsedRange.SpecialCells(xlCellTypeLastCell).Row
.Rows(LastRow).Copy .Rows(LastRow + 2)
.Range("B3").Copy .Cells(LastRow + 2, 1)
End With
'Lägg till information för lista
With Sheets("Lista")
'Hittar sista raden och ger den ett nummer
LastRow = .Cells("A65536").End(xlUp).Row
Sheets("uppdatera").Range("B3").Copy .Cells(LastRow + 1, 1)
.Cells(LastRow + 1, 1).Copy .Cells(1, LastRow + 1)
'ADD NEW LINES HERE
ActiveWorkbook.Names.Add Name:=Replace(.Cells(1, LastRow + 1), " ", "_"), RefersToR1C1:="=" & .Name & "!" & .Cells(1, LastRow + 1).Address
ActiveWorkbook.Names.Add Name:=Replace(.Cells(1, LastRow + 1), " ", "_") & "Col", RefersToR1C1:="=" & .Name & "!" & .Cells(1, LastRow + 1).Address
End With
'Gå tillbaka till Uppdatering
Application.CutCopyMode = False
End Sub
Note that you could get rid of copying altogether by simply saying
.Cells(1,LastRow +1).Value = .Cells(LastRow + 1,1).Value
but this would only transfer the values, not the formatting or formulas. If you wanted the formulas instead, you would replace.Value with .Formula. If you want the formatting, then you would just leave the .Copy method above.
Bookmarks