Hello, here is my very first macro, it takes values from sheet1 and adds it do diffrent sheets, but the user have to create the sheets manually,
blad is the swedish name for sheet
sub bynamn()
On Error GoTo HandleErr
'blad 2
'blad namn
Blad2.Name = Blad1.Range("C7")
Blad1.Range("C7").Copy Destination:=Blad2.Range("F4")
Blad1.Range("D7").Copy Destination:=Blad2.Range("B1")
/this row does not work becouse F40 is a sum of diffrent cells.
'Blad2.Range("F40").Paste Destination:=Blad1.Range("E7").Value
Blad3.Name = Blad1.Range("C8")
Blad1.Range("C8").Copy Destination:=Blad3.Range("F4")
Blad1.Range("D8").Copy Destination:=Blad3.Range("B1")
Blad4.Name = Blad1.Range("C9")
Blad1.Range("C9").Copy Destination:=Blad4.Range("F4")
Blad1.Range("D9").Copy Destination:=Blad4.Range("B1")
Blad5.Name = Blad1.Range("C10")
Blad1.Range("C10").Copy Destination:=Blad5.Range("F4")
Blad1.Range("D10").Copy Destination:=Blad5.Range("B1")
Blad6.Name = Blad1.Range("C11")
Blad1.Range("C11").Copy Destination:=Blad6.Range("F4")
Blad1.Range("D11").Copy Destination:=Blad6.Range("B1")
Blad7.Name = Blad1.Range("C12")
Blad1.Range("C12").Copy Destination:=Blad7.Range("F4")
Blad1.Range("D12").Copy Destination:=Blad7.Range("B1")
Blad8.Name = Blad1.Range("C13")
Blad1.Range("C13").Copy Destination:=Blad8.Range("F4")
Blad1.Range("D13").Copy Destination:=Blad8.Range("B1")
ExitHere:
Exit Sub
HandleErr:
Select Case Err.Number
Case Else
MsgBox Err.Description & " inga mer blad" & Err.Number
Resume ExitHere
End Select
End Sub
blad is the swedish name for sheet
sub bynamn()
On Error GoTo HandleErr
'blad 2
'blad namn
Blad2.Name = Blad1.Range("C7")
Blad1.Range("C7").Copy Destination:=Blad2.Range("F4")
Blad1.Range("D7").Copy Destination:=Blad2.Range("B1")
/this row does not work becouse F40 is a sum of diffrent cells.
'Blad2.Range("F40").Paste Destination:=Blad1.Range("E7").Value
Blad3.Name = Blad1.Range("C8")
Blad1.Range("C8").Copy Destination:=Blad3.Range("F4")
Blad1.Range("D8").Copy Destination:=Blad3.Range("B1")
Blad4.Name = Blad1.Range("C9")
Blad1.Range("C9").Copy Destination:=Blad4.Range("F4")
Blad1.Range("D9").Copy Destination:=Blad4.Range("B1")
Blad5.Name = Blad1.Range("C10")
Blad1.Range("C10").Copy Destination:=Blad5.Range("F4")
Blad1.Range("D10").Copy Destination:=Blad5.Range("B1")
Blad6.Name = Blad1.Range("C11")
Blad1.Range("C11").Copy Destination:=Blad6.Range("F4")
Blad1.Range("D11").Copy Destination:=Blad6.Range("B1")
Blad7.Name = Blad1.Range("C12")
Blad1.Range("C12").Copy Destination:=Blad7.Range("F4")
Blad1.Range("D12").Copy Destination:=Blad7.Range("B1")
Blad8.Name = Blad1.Range("C13")
Blad1.Range("C13").Copy Destination:=Blad8.Range("F4")
Blad1.Range("D13").Copy Destination:=Blad8.Range("B1")
ExitHere:
Exit Sub
HandleErr:
Select Case Err.Number
Case Else
MsgBox Err.Description & " inga mer blad" & Err.Number
Resume ExitHere
End Select
End Sub