Having some issues with my snippet of code...

eskelies

Board Regular
Joined
May 27, 2010
Messages
95
The following code keeps multiplying by a million instead of ending once the next cell is blank or has a zero. Do I need to have an offset? If so, how should it look?

Code:
          Set myRange = Range("B10:B20")
For Each c In myRange
        
        If IsNumeric(c) Then
            c.Value = c.Value * 1000000
        Else
            c.Value = ("")
        End If
Next
   For Each cell In [B11:B20]
If cell.Value = "0" Then cell.ClearContents
Next cell
Next
 
Range("A10:G20").Copy Destination:=Sheets("Sheet2").Range("H11")


any help would be useful.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
Code:
    For Each c In myRange
        
        If c.Value <> "" Then
        
            If IsNumeric(c.Value) Then
                c.Value = c.Value * 1000000
            Else
                c.Value = ("")
            End If
        End If
    Next
 

eskelies

Board Regular
Joined
May 27, 2010
Messages
95
nothing changed on this. It increases exponentially by a million instead of only increasing by a million once.
 
Last edited:

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
If you REALLY want to end

Code:
    For Each c In myRange
        
        If c.Value <> "" Then
        
            If IsNumeric(c.Value) Then
                c.Value = c.Value * 1000000
            Else
                Exit For
            End If
        End If
    Next
 

eskelies

Board Regular
Joined
May 27, 2010
Messages
95

ADVERTISEMENT

Still isn't working properly. I'm getting exponentials to the 279th power.


If you REALLY want to end

Code:
    For Each c In myRange
 
        If c.Value <> "" Then
 
            If IsNumeric(c.Value) Then
                c.Value = c.Value * 1000000
            Else
                Exit For
            End If
        End If
    Next
 

Saffa84

New Member
Joined
Apr 29, 2010
Messages
19
The following code keeps multiplying by a million instead of ending once the next cell is blank or has a zero. Do I need to have an offset? If so, how should it look?

Code:
          Set myRange = Range("B10:B20")
For Each c In myRange
 
        If IsNumeric(c) Then
            c.Value = c.Value * 1000000
        Else
            c.Value = ("")
        End If
Next
   For Each cell In [B11:B20]
If cell.Value = "0" Then cell.ClearContents
Next cell
Next
 
Range("A10:G20").Copy Destination:=Sheets("Sheet2").Range("H11")


any help would be useful.

You original code works fine for me if I take out the extra "Next" at the end.
 

eskelies

Board Regular
Joined
May 27, 2010
Messages
95
Unfortunately for me it continuously multiplys by 1mm. Now it could be because that was only part of the code.
 
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,163,493
Messages
5,832,015
Members
430,104
Latest member
briannnnleong

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