VBA Macro in button click error

jawaharprm

New Member
Joined
Dec 3, 2016
Messages
4
Hi iam Jawahar,
Assigined button in sheet 1 and code to process in sheet2 but macro is not running please help.

Sub Button2_Click()
Dim i As Integer
i = 2
Do While Sheet2.Cells(i, 2) <> ""
Cells(i, 38) = Cells(i, 36) - Cells(i, 37)
i = i + 1
Loop
For i = 1 To 10000
If (Cells(i, 39) = "") Then
Exit For
Else
If ((Cells(i, 39) = "706")) Then Cells(i, 39) = "6"
If ((Cells(i, 39) = "703")) Then Cells(i, 39) = "3"
If ((Cells(i, 39) = "702")) Then Cells(i, 39) = "2"
If ((Cells(i, 39) = "704")) Then Cells(i, 39) = "4"
If ((Cells(i, 39) = "713")) Then Cells(i, 39) = "13"
If ((Cells(i, 40) = "")) Then Cells(i, 40) = 0
End If
Next i
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Please tell us what your wanting to do instead of thinking we should understand your script which is not doing what you want.

Here is my script which is not working please help me with no explanation is not much help.
 
Upvote 0
Please tell us what your wanting to do instead of thinking we should understand your script which is not doing what you want.

Here is my script which is not working please help me with no explanation is not much help.


Hi,

wrote a script updatiing some cloums as given in script, i like to tag the script under button_clidk but the script is not running, Please help.
 
Upvote 0
If statements should be written like this:

If Cells(i, 39).value = "706" Then Cells(i, 39) = "6"
Not like this:

If ((Cells(i, 39) = "706")) Then Cells(i, 39) = "6"
 
Upvote 0
If statements should be written like this:

If Cells(i, 39).value = "706" Then Cells(i, 39) = "6"
Not like this:

If ((Cells(i, 39) = "706")) Then Cells(i, 39) = "6"


Hi thanks,

If ((Cells(i, 39) = "706")) Then Cells(i, 39) = "6" this if statment is working fine but my query is the entire code is not working under button click there is any code to add to run the code in button_click.
 
Upvote 0
What happens if you put Sheet2. in front of everywhere it says Cells.
As M.A.I.T. has stated you don't need the extra brackets and you also don't need the quotes around the numbers if they are actual numbers and not text.
 
Upvote 0

Forum statistics

Threads
1,214,427
Messages
6,119,419
Members
448,895
Latest member
omarahmed1

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