if statement what's wrong?

earp_

Active Member
Joined
Apr 30, 2008
Messages
305
Hi, i have this
If (valueCellMyMacro1<> 0) Then
Worksheets("daily1").Range(colSheet2MyMacro1).End(xlUp).Offset(1, 0).Value = valueCellMyMacro1
End If
where
Dim valueCellMyMacro1 As Range
Set valueCellMyMacro1 = Worksheets("Sheet1").Range("B2")
that should say that "if the value in 'valueCellMyMacro1' is NOT zero then assign the value 'valueCellMyMacro1 ' to the Sheet 'daily1 with range that goes from the top to the buttom'

Now, if i open another excel file I've got an error "run time erro '9' subscript out of range"

the second file has
QUOTE]
If (valueCellMyMacro2<> 0) Then
Worksheets("daily2").Range(colSheet2MyMacro2).End(xlUp).Offset(1, 0).Value = valueCellMyMacro2
End If
[/QUOTE]
where
Dim valueCellMyMacro2 As Range
Set valueCellMyMacro2 = Worksheets("Sheet1").Range("B2")
I will try now to put also the woorkbook, just in case.
But do you think that the problem is why i didn't put the Workbook?
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
it's just a number I don't want to add in my column the value 0, that's why i put that if
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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