run time error issue in VBA

TommyNewtoExcel

New Member
Joined
Nov 4, 2019
Messages
6
Hello,
I am new to excel VBA and have been getting stuck on the "run-time error'1004. The formula is missing a range reference or a defined name" the error is in the following line Range("RIFEquipmentTag").Value = RIFEquipmentTag

I believe I have set it up the same way as the other items pulling data and entering into a new block but have obviously not done something right. The first three of these run correctly but it keeps giving me an error on the above line.

I am taking form a range as defined on another sheet and sending to fill a new form in a block named Equipment Tag and comes forma column named unit ID.

Any help would be greatly appreciated.
Thank you in advance,
TommyC


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
[code]
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi & welcome to MrExcel.
Check that you have a named range called "RIFEquipmentTag", especially check for any typos.
 
Upvote 0
Thank you Fluff. have checked and don't see where i have any misspellings or other issues and I do have a range for it defined. the range is listed for the source of data I am trying to get RIFEquipmentTag = Range("AHUData").Cells(i, 2).Value

 
Upvote 0
If you go to Name Manager and select "RIFEquipmentTag", what does it say in the Refers To box?
Also is it defines as sheet, or workbook scope?
 
Upvote 0
Glad you sorted it & thanks for the feedback
 
Upvote 0
Thank you for the help. the question promoted me to search and found when clicking on cells referenced other places the name was changing vice being labeled C3. then realized the same was not true for the one I was referencing. Thanks again.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
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