Problem with an Excel 365 VBA Macro filling out a table

DThib

Active Member
Joined
Mar 19, 2010
Messages
464
Office Version
  1. 365
Platform
  1. Windows
Help!

I have a portion of the code giving me problems below. The red code line below is throwing an Error I cannot find
Error message: "Run-time error '91': Object variable or With block variable not set"
All names match, all entities identify as the code is running until this step.
Can anyone point me in the right direction?
Set frVS08EC1FTS = TBViaS08EC1FTS.Find(what:=celVS08EC1FTS.Value, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
VBA Code:
Sub ViabSurf08_ECAs_FTS_Thing()

    Dim EMW1, Part1 As Workbook
    Dim Ws1, Ws2b  As Worksheet
    Dim ViabSurf08_ECA1_FTS, ViabSurf08_ECA2_FTS, ViabSurf08_ECA3_FTS, ViabSurf08_ECA4_FTS, ViaS08ECA1FTS, ViaS08ECA2FTS, ViaS08ECA3FTS, ViaS08ECA4FTS As ListObject
    'Dim CViaS08ECA1FTS, CViaS08ECA2FTS, CViaS08ECA3FTS,, CViaS08ECA4FTS As ListColumn
    Dim TBViaS08EC1FTS, TBViaS08EC2FTS, TBViaS08EC3FTS, TBViaS08EC4FTS, celVS08EC1FTS, celVS08EC2FTS, celVS08EC3FTS, celVS08EC4FTS, frVS08EC1FTS, frVS08EC2FTS, frVS08EC3FTS, frVS08EC4FTS As Range
    Dim oNewRow As ListRow
    Dim AdVS08EC1FTS, AdVS08EC2FTS, AdVS08EC3FTS, AdVS08EC4FTS As String
  
  
      Set EMW1 = Workbooks("Environmental Monitoring v0.5b.xlsm")
        With EMW1
         Set Ws1 = .Sheets("Viable FingerTip-Sleeve")
            Set ViabSurf08_ECA1_FTS = Ws1.ListObjects("ISO8G_ViableSurf_ECA1_FTS")
            Set ViabSurf08_ECA2_FTS = Ws1.ListObjects("ISO8G_ViableSurf_ECA2_FTS")
            Set ViabSurf08_ECA3_FTS = Ws1.ListObjects("ISO8G_ViableSurf_ECA3_FTS")
            Set ViabSurf08_ECA4_FTS = Ws1.ListObjects("ISO8G_ViableSurf_ECA4_FTS")
        End With
        With ViabSurf08_ECA1_FTS
         Set TBViaS08EC1FTS = .ListColumns("Test Date").DataBodyRange
        End With
        With ViabSurf08_ECA2_FTS
         Set TBViaS08EC2FTS = .ListColumns("Test Date").DataBodyRange
        End With
        With ViabSurf08_ECA3_FTS
         Set TBViaS08EC3FTS = .ListColumns("Test Date").DataBodyRange
        End With
        With ViabSurf08_ECA4_FTS
         Set TBViaS08EC4FTS = .ListColumns("Test Date").DataBodyRange
        End With
  
      Set Part1 = Workbooks("Viables_Test.xlsx")
         With Part1
          Set Ws2b = .Sheets("Viable FingerTip-Sleeve")
          With Ws2b
            Set ViaS08ECA1FTS = .ListObjects("ECA1_T1_ViaSurf_FTS")
            Set ViaS08ECA2FTS = .ListObjects("ECA2_T1_ViaSurf_FTS")
            Set ViaS08ECA3FTS = .ListObjects("ECA3_T1_ViaSurf_FTS")
            Set ViaS08ECA4FTS = .ListObjects("ECA4_T1_ViaSurf_FTS")
          End With
         End With

     With ViaS08ECA1FTS
      Set CViaS08ECA1FTS = .ListColumns("Test Date").DataBodyRange
     End With
     With ViaS08ECA2FTS
      Set CViaS08ECA2FTS = .ListColumns("Test Date").DataBodyRange
     End With
     With ViaS08ECA3FTS
      Set CViaS08ECA3FTS = .ListColumns("Test Date").DataBodyRange
     End With
     With ViaS08ECA4FTS
      Set CViaS08ECA4FTS = .ListColumns("Test Date").DataBodyRange
     End With

  ' Copy the ECA 1 Finger Tip and Sleeve Viable TI columns
    For Each celVS08EC1FTS In CViaS08ECA1FTS
    'something is up!!!
    Set frVS08EC1FTS = TBViaS08EC1FTS.Find(what:=celVS08EC1FTS.Value, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
      'AdVS08EC1FTS = celVS08EC1FTS.Address
     If Not frVS08EC1FTS Is Nothing Then
       If frVS08EC1FTS.Cells(, 2) = "" Then
        frVS08EC1FTS.Cells(, 2) = celVS08EC1FTS.Offset(, 2).Value
       End If
     End If
     If frVS08EC1FTS Is Nothing Then   'meaning it was not found
        AdVS08EC1FTS = celVS08EC1FTS.Address
         With ViabSurf08_ECA1_FTS
            Set oNewRow = .ListRows.Add
             With oNewRow.Range
               If .Cells(, 1).Value = celVS08EC1FTS.Offset(, 0).Value Then
                  .Cells(, 2) = celVS08EC1FTS.Offset(, 2).Value
                  .Cells(, 3) = celVS08EC1FTS.Offset(, 3).Value
               Else
                  .Cells(, 1).Value = celVS08EC1FTS.Offset(, 0).Value
                  .Cells(, 2) = celVS08EC1FTS.Offset(, 2).Value
                  .Cells(, 3) = celVS08EC1FTS.Offset(, 3).Value
               End If
             End With
        End With
      End If
    Next celVS08EC1FTS
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
A couple of things I noticed. First, you are not using "Option Explicit" because you have some undeclared variables. Secondly, the way you are declaring your variables, as of right now you have declared only one "ListObject"- "ViaS08ECA4TS" and only one Range- "frVS08EC4FTS".

In your code, everything in these two declarations are being declared as Variants, except for what I noted above...

VBA Code:
Dim ViabSurf08_ECA1_FTS, ViabSurf08_ECA2_FTS, ViabSurf08_ECA3_FTS, ViabSurf08_ECA4_FTS, ViaS08ECA1FTS, ViaS08ECA2FTS, ViaS08ECA3FTS, ViaS08ECA4FTS As ListObject
'Dim CViaS08ECA1FTS, CViaS08ECA2FTS, CViaS08ECA3FTS,, CViaS08ECA4FTS As ListColumn
Dim TBViaS08EC1FTS, TBViaS08EC2FTS, TBViaS08EC3FTS, TBViaS08EC4FTS, celVS08EC1FTS, celVS08EC2FTS, celVS08EC3FTS, celVS08EC4FTS, frVS08EC1FTS, frVS08EC2FTS, frVS08EC3FTS, frVS08EC4FTS As Range

The same holds true for this line. Everything is being declared as a variant except for "AdvS08EC4FTS" which has been declared a String.

VBA Code:
Dim AdVS08EC1FTS, AdVS08EC2FTS, AdVS08EC3FTS, AdVS08EC4FTS As String

I don't think that is what you are intending. Unless you use shorthand ($,%,&,!,) etc, then you must declare all variables. They can be on the same line, but each varible must have "as ListObject" or as "String". like this for example.

VBA Code:
Dim AdVS08EC1FTS As String, AdVS08EC2FTS As String, AdVS08EC3FTS As String, AdVS08EC4FTS As String

Without trying to duplicate your code, I think this is why you are getting your error.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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