KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 460
- Office Version
- 2016
- Platform
- Windows
Hi, I have a little challenge. I use this VBA code to consolidate my sheets. It works really well.
I would like the data to be inserted in K9, but do not know how to do.
All help will be appreciated.
Best Regards
Klaus W
I would like the data to be inserted in K9, but do not know how to do.
All help will be appreciated.
Best Regards
Klaus W
VBA Code:
Sub Opsamling()
Dim wksHent As Range
Dim wksSaml As Worksheet
Dim sidsterk As Long
Dim kopiomr As Range
Dim kolonner As Variant
kolonner = Split(Names("HentKolonner").RefersToRange.Value2, ":")
Set wksSaml = Worksheets(Names("SamlearkNavn").RefersToRange.Value2)
wksSaml.Cells.ClearContents
For Each wksHent In Names("OpsamlingFra").RefersToRange.Cells
sidsterk = Worksheets(wksHent.Value2).Range("A" & Worksheets(wksHent.Value2).Rows.Count).End(xlUp).Row
'kopi dataomkr
Set kopiomr = Worksheets(wksHent.Value2).Range(kolonner(0) & "2:" & kolonner(1) & sidsterk)
wksSaml.Range("k" & wksSaml.Rows.Count).End(xlUp).Offset(1, 0).Resize(kopiomr.Rows.Count, kopiomr.Columns.Count).Value2 = kopiomr.Value2
'kopi overskrift
'wksSaml.Range("A1").EntireRow.Value2 = Worksheets(wksHent.Value2).Range("A1").EntireRow.Value2
Next
End Sub