Good afternoon,
I am trying to write a piece of VBA code which will perform an action (clearing the contents of certain cells) but will only act in a range of cells based on the contents of another cell.
The basic code i am trying to use is as follows (as an extract):
This row keeps coming up as a run time error '1004' Application-defined or object defined error.
For what it's worth i have DIM j & k as integers at the beginning of the whole process.
I'm not sure if it's that line itself which is causing the issue, or the way i have tried to specify 'k' in the initial part of my code.
If anyone could give me a little bit of a steer as to what might be causing the issue i would be eternally grateful!
Thanks in advance!
Wayner
I am trying to write a piece of VBA code which will perform an action (clearing the contents of certain cells) but will only act in a range of cells based on the contents of another cell.
The basic code i am trying to use is as follows (as an extract):
Code:
Sheets("User Interface").Select
If Range("HRTSelect") = "Supergroup" Then k = 7
If Range("HRTSelect") = "Group" Then k = 10
If Range("HRTSelect") = "Upcs" Then k = 13
For j = 4 To 205
If Cells(j, k + 1) = Range("HRTSpecify") And Cells(j + 1, k) = "" Then
Cells(j, k).ClearContents
If Range("HRTSelect") = "Upcs" Then
Range(Cells(j, k + 2), Cells(j, k + 8)).ClearContents
End If
End If
Next j
Code:
If Cells(j, k + 1) = Range("HRTSpecify") And Cells(j + 1, k) = "" Then
I'm not sure if it's that line itself which is causing the issue, or the way i have tried to specify 'k' in the initial part of my code.
If anyone could give me a little bit of a steer as to what might be causing the issue i would be eternally grateful!
Thanks in advance!
Wayner