I am very new to VBA. runtime error 424
starts when I try to set value1 =
. Can't quite seem to figure this one out. I am dealing with imported data. Negative numbers are imported with the CR suffix going to an adjacent column. I need excel to recognize the CR and make the cell next to it negative or what I have tried now is to return the negative value in a third column. The data skips rows so I only need the true negative numbers to be translated everything else should return a blank.
I have tried conditional formatting using an if equation which worked well but when translated to VBA the relative cell references and formulas were messy and not user freindily in case of format changes,
included the problem parts of the code.
Thanks in advance to anyone who can help!
Application.ScreenUpdating = False
Sheet2.Range("A1:H9999").ClearContents
Dim vFileName
Dim MyWorkbook As Workbook
Dim NameColumn As Range
Dim value1 As Range
Dim value2 As Range
Dim value3 As Integer
vFileName = Application.GetOpenFilename("Text Files (*.txt),*.txt")
MyWorkbook.Activate
Application.DisplayAlerts = False
ActiveWindow.Close
Set value1 = Worksheet.Range("K113:K249")
Set value2 = Worksheet.Range("H113:H249")
Set NameColumn = Worksheet.Range("I113:I249")
If NameColumn.Value = "CR" Then
value1.Value = value1.Value * -1
ElseIf value2.Value = 0 Or "" Then
value1.Value = ""
Else: value1.Value = value1.Value
End If