Consolidate my sheets with formulas

KlausW

Active Member
Joined
Sep 9, 2020
Messages
378
Office Version
  1. 2016
Platform
  1. Windows
Hi, I have a little challenge. I use this VBA code to consolidate my sheets. It works really well. Now I have inserted formulas in columns A to H. When I run the VBA code, it does not run. I think it must be because formulas have come in. Some that can help get it running.
All help will be appreciated.
Best Regards
Klaus W
VBA Code:
Sub Rektangelafrundedehjørner4_Klik()

    Dim ws As Worksheet, wsConsol As Worksheet
    Dim lngLastRow As Long, lngPasteRow As Long
   
    Application.ScreenUpdating = False
   
    Set wsConsol = ThisWorkbook.Sheets("Bestilling")
    lngPasteRow = 9 'Starting Row number for the consolidation of the sheet data in 'wsConsol'.
   
    For Each ws In ThisWorkbook.Sheets
        

        If ws.Name <> wsConsol.Name And ws.Name <> "Fra fil" Then


        'If ws.Name <> wsConsol.Name Then
            On Error Resume Next
                lngLastRow = ws.Range("A:I").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
            On Error GoTo 0
            If lngLastRow >= 2 Then
                ws.Range("A2:I" & lngLastRow).Copy Destination:=wsConsol.Range("K" & lngPasteRow)
                lngPasteRow = wsConsol.Range("K:S").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
            End If
        End If
    Next ws

           
            Range("K9:K15000").NumberFormat = "General"
            Range("K9:K15000").Value = Range("K9:K15000").Value
    
    
   
    Application.ScreenUpdating = True
    
    Sheets("Bestilling").Select
    Macro1

End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try this:

VBA Code:
Sub Rektangelafrundedehjørner4_Klik()
  Dim ws As Worksheet, wsConsol As Worksheet
  Dim lngLastRow As Long, lngPasteRow As Long
  
  Application.ScreenUpdating = False
  
  Set wsConsol = ThisWorkbook.Sheets("Bestilling")
  lngPasteRow = 9 'Starting Row number for the consolidation of the sheet data in 'wsConsol'.
  
  For Each ws In ThisWorkbook.Sheets
    Select Case ws.Name
      Case wsConsol.Name, "Fra fil"
      Case Else
        On Error Resume Next
        lngLastRow = ws.Range("A:I").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        On Error GoTo 0
        If lngLastRow >= 2 Then
          ws.Range("A2:I" & lngLastRow).Copy
          wsConsol.Range("K" & lngPasteRow).PasteSpecial xlPasteValues
          wsConsol.Range("K" & lngPasteRow).PasteSpecial xlPasteFormats
          lngPasteRow = wsConsol.Range("K:S").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
        End If
    End Select
  Next ws
  
  wsConsol.Range("K9:K" & lngPasteRow).NumberFormat = "General"
  Application.ScreenUpdating = True
  Sheets("Bestilling").Select
  Macro1
End Sub
 
Upvote 0
Solution
Hi Dante Amor it work perfekt, thank very much. Best regards Klaus W
 
Upvote 0

Forum statistics

Threads
1,214,521
Messages
6,120,018
Members
448,937
Latest member
BeerMan23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top