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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

earp_

Active Member
Joined
Apr 30, 2008
Messages
305
it's just a number I don't want to add in my column the value 0, that's why i put that if
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,684
Messages
5,838,794
Members
430,569
Latest member
sbardelli

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
Top