changing cell value in vba

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
If I want to change a cell value then I can write this code

Code:
sub abc[INDENT]thisworkbook.activesheet.cells(1,1).value =10[/INDENT]
end sub

but I can also do that by writing this code
Code:
sub abc[INDENT]cells(1,1).value =10[/INDENT]
end sub

I see both give the same result. I do not see any advantage of one on another except the second one is easier to type. Which one is the right one? is there any cases I can only use one over the other? thank you so much
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
If you are working in more than one workbook or worksheets, then you may wish to use the first variation. For most situations, the second scenario should work for you.
 
Upvote 0
With Excel you can do almost anything several different ways.
Now which is best or fastest is all up for debate.
Here is another way:

[A1]= 10
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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