I've got some bits of code that is repeating itself many times, and I'm also using them on several "group-runs", so I'm re-using my code a lot. So, I'm trying to declare some values in such a way that I can change this only one time at the top of each run. Below I'm trying to declare a sheet name and a row number at the top, but I'm only getting a "variable not defined" error. Anyone that can help me how to declare these two values correct - and how to put them correct in to my code (other declarations is already done, and working).
Dim grsh, ntid As String
grsh = s1g1
ntid = 2289
Application.StatusBar = "Now updating: & grsh & (new report data)." 'grsh
lr = sh_2_fravær.Range("A" & Rows.Count).End(xlUp).Row
sh_2_fravær.Range("A3:E" & lr).ClearContents
Set wb_Fravær = Workbooks("Fravær.xlsm")
lr = wb_Fravær.Sheets("grsh").Range("A" & Rows.Count).End(xlUp).Row 'grsh
wb_Fravær.Sheets("grsh").Range("A4:D" & lr).Copy 'grsh
sh_2_fravær.Range("A3").PasteSpecial
Application.CutCopyMode = False
lr = sh_11_tid.Range("A" & Rows.Count).End(xlUp).Row
sh_11_tid.Range("A&ntid:L" & lr).ClearContents 'ntid
Set wb_Tidsbruk = Workbooks("Tidsbruk.xlsm")
lr = wb_Tidsbruk.Sheets("grsh").Range("A" & Rows.Count).End(xlUp).Row 'grsh
wb_Tidsbruk.Sheets("grsh").Range("A5:I" & lr).Copy 'grsh
sh_11_tid.Range("A&ntid").PasteSpecial 'ntid
Application.CutCopyMode = False
Dim grsh as string, ntid As Long2.lr = wb_Fravær.Sheets(grsh).Range("A" & Rows.Count).End(xlUp).Row3.sh_11_tid.Range("A" & ntid & ":L" & lr).ClearContents4.lr = wb_Tidsbruk.Sheets(grsh).Range("A" & Rows.Count).End(xlUp).Row5.wb_Tidsbruk.Sheets(grsh).Range("A5:I" & lr).Copy6.sh_11_tid.Range("A" & ntid).PasteSpecialApplication.StatusBar = "Now updating: "& grsh & " (new report data)."grsh = "s1g1"grsh = s1g1at the top.grsh = "s1g1", it worked just fine! Thanks a lot for helping out.