pmgibs

New Member
Joined
Apr 5, 2017
Messages
16
I have the below code that works:

Code:
Private Sub CommandButton1_Click()
Dim cell As Range
For Each cell In Range("I2:I2")
cell.Formula = Replace(cell.Formula, "100,", TextBox1.Value + ",")
cell.Formula = Replace(cell.Formula, "260000000000,", TextBox2.Value + ",")
Next cell
End Sub

But, I would like to be able to input a smaller value in TexBox2, such as 3.0, and then multiply it by 100,000,000,000. So in the case above if 3.0 was entered into Textbox2, "260000000000," would be replaced by "300000000000,".

When I try the code below I encounter a Run time error '13': Type mismatch.

Code:
Private Sub CommandButton1_Click()Dim cell As Range
For Each cell In Range("I2:I2")
cell.Formula = Replace(cell.Formula, "100,", TextBox1.Value + ",")
cell.Formula = Replace(cell.Formula, "260000000000,", TextBox2.Value * 100000000000# + ",")
Next cell
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try
Code:
cell.Formula = Replace(cell.Formula, "260000000000,", TextBox2.Value * 100000000000# [COLOR=#ff0000]&[/COLOR] ",")
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,814
Messages
6,121,711
Members
449,049
Latest member
THMarana

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