run time error issue in VBA

Status
Not open for further replies.

TommyNewtoExcel

New Member
Joined
Nov 4, 2019
Messages
6
I am receiving a runtime error 1004 in VBA. It has been driving me crazy. I run a similar line of code three times before this one and this is the only one I am getting hung up on. Somehow it seems I have improperly set the range? It is giving the reference is not valid.

Any help would be greatly appreciated.

Thank you in advance,
TommyC


Issue is here in the second row of code and the full code is below.
'EquipmentTag
Application.Goto Reference:="RIFEquipmentTag"
Range("RIFEquipmentTag").Value = RIFEquipmentTag

Code:
Public Sub GenerateRIF()
Dim i As Integer
Dim x As Integer
Dim FilePath As String
Dim FullFileName As String
Dim wbkCurrent As Workbook
Dim RIFManufacturer As String
Dim RIFType As String
Dim RIFCapacity As String
Dim RIFVoltage As String
Dim RIFEquipmentTag As String


Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual


i = 1
x = Application.WorksheetFunction.CountA(Range("B:B"))


'Update to your file path"
FilePath = "C:C:\Users\thocoult\Desktop\Newst macro\"


Set wbkCurrent = ActiveWorkbook


Application.Goto Reference:="AHUData"
Range("AHUData").Cells(i, 2).Select


'Hard code building id in all of the forms
buildingFINId = "IAD65"


For i = 1 To x
    
    Application.Goto Reference:="AHUData"
    
    RIFManufacturer = Range("AHUData").Cells(i, 4).Value
    RIFType = Range("AHUData").Cells(i, 7).Value
    RIFCapacity = Range("AHUData").Cells(i, 7).Value
    RIFVoltage = Range("AHUData").Cells(i, 29).Value
    RIFEquipmentTag = Range("AHUData").Cells(i, 2).Value
    
    If Left(Range("AHUData").Cells(i, 2).Value, 3) = "AHU" Then
    
    'Manufacturer
    Application.Goto Reference:="RIFManufacturer"
    Range("RIFManufacturer").Value = RIFManufacturer
    
    'Type
    Application.Goto Reference:="RIFType"
    Range("RIFType").Value = RIFType
    
    'Capacity
    Application.Goto Reference:="RIFCapacity"
    Range("RIFCapacity").Value = RIFCapacity
    
    'Volts/Phase/Hertz
    Application.Goto Reference:="RIFVoltage"
    Range("RIFVoltage").Value = RIFVoltage
    
    'EquipmentTag
    Application.Goto Reference:="RIFEquipmentTag"
    Range("RIFEquipmentTag").Value = RIFEquipmentTag


    FullFileName = FilePath & "RIF_" & Range("AHUData").Cells(i, 2).Value & ".xlsx"
    
'        If i = 1 Then
    Worksheets("RIF").Copy
    ActiveWorkbook.SaveAs FileName:=FullFileName, FileFormat:=xlOpenXMLWorkbook
    ActiveWorkbook.Close


    wbkCurrent.Activate
    
    End If
Next i


'turning back on auto calculations
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True


End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Duplicate https://www.mrexcel.com/forum/excel-questions/1114096-run-time-error-issue-vba.html#post5366150

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

Note that sometimes posts from new users require Moderator approval before you can see them on the public forums. When this happens, you should see a message to that effect when you try to post it.
Please be patient and do not attempt to post the question again.

 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,886
Messages
6,175,193
Members
452,616
Latest member
intern444

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