"The specified dimension is not valid for the current chart type" error

KhallP

Board Regular
Joined
Mar 30, 2021
Messages
157
Office Version
  1. 2016
Platform
  1. Windows
I created a macro to insert data from an excel spreadsheet into another Excel file, but when I run the program the error "the specified dimension is not valid for the current chart type", can someone help me?



Variables (Module2)

Code:
Option Explicit

Public myRecentFile As String
Public counter As Integer, counter2 As Integer, ws As Integer, ws2 As Integer, res_1, res_2
Public sh As Worksheet, ch As Worksheet
Public k As Long





MyRecentFile Sub

VBA Code:
Public Sub recentFilesSpecificFolder()

    res_1 = 0
    res_2 = 0
    counter = 1
    counter2 = 4
  
    ws2 = Workbooks("EEC QEC.xlsm").Sheets.Count
    k = Workbooks("EEC QEC.xlsm").Worksheets("QEC 1.2 - montagem").Cells(Rows.Count, "H").End(xlUp).Offset(1).Row

    Dim myFile As String, fileExtension As String, recentDate As Date

    myDirectory = Environ("userprofile") & "\Documents\Projeto_Luis\Andre\EEC\QE"
    fileExtension = "*.xls"

    If Right(myDirectory, 1) <> "\" Then myDirectory = myDirectory & "\"

    myFile = Dir(myDirectory & fileExtension)
    If myFile <> "" Then
        myRecentFile = myFile
        recentDate = FileDateTime(myDirectory & myFile)
        Do While myFile <> ""
            If FileDateTime(myDirectory & myFile) > recentDate Then
                myRecentFile = myFile
                recentDate = FileDateTime(myDirectory & myFile)
            End If
        myFile = Dir
        Loop
    End If
    MsgBox "Path: " & myDirectory & vbCrLf & "File: " & myMostRecentFile
    ws = Workbooks(myRecentFile).Sheets.Count
    Call WriteCells

End Sub




WriteCells


Code:
Public Sub WriteCells()
   
    If counter = 16 & counter2 = 20 Then
        counter = 1
        Call Fill_2021
       
    Else
        Call FillSheets
       
    End If

End Sub





Program (Module1)

VBA Code:
Set ch = Workbooks(myRecentFile).Worksheets(counter)
            Set sh = Workbooks("EEC QEC.xlsm").Worksheets(counter2)
            If ch.Name = "QEC 12 IF" Or ch.Name = "QEC 22 IF" Or ch.Name = "QEC 24 IF" Or ch.Name = "QEC 41 IF" Or ch.Name = "QEC 42 IF" Or ch.Name = "QEC 43 IF" Or ch.Name = "QEC 44 IF" Then
                If sh.Name = "QEC 1.2 - montagem" Or sh.Name = "QEC 2.2 -SALA LIMPA" Or sh.Name = "QEC 2.4 Logística" Or sh.Name = "QEC 4.1 - MONTAGEM MANUAL(past)" Or sh.Name = "QEC 4.2 - Desmoldagem" Or sh.Name = "QEC 4,3 - RTM" Or sh.Name = "QEC 4,4 - HOT DRAPE" Then
                    If Range("H" & k).Value = "" Then
                        ch.Range("W110").Copy _
                        sh.Range("H" & k)
                        ch.Range("AI110").Copy _
                        sh.Range("I" & k)
                 
                    Else
                    Do Until ActiveCell.Value = ""
                        ActiveCell.Offset(1).Select
                        res_1 = res_1 + 1
                    Loop
             
                        ch.Range("W110").Copy _
                        sh.Range("H" & (k + res_1))
                        ch.Range("AI110").Copy _
                        sh.Range("I" & (k + res_1))
                        res_1 = Empty
             
                    End If
                End If
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,215,464
Messages
6,124,967
Members
449,200
Latest member
Jamil ahmed

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