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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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
 
Upvote 0
nothing changed on this. It increases exponentially by a million instead of only increasing by a million once.
 
Last edited:
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
Unfortunately for me it continuously multiplys by 1mm. Now it could be because that was only part of the code.
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,238
Members
448,555
Latest member
RobertJones1986

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