setting values in a sheet without changing the focus

deadseasquirrels

Board Regular
Joined
Dec 30, 2004
Messages
232
If I have multiple sheets up, and I want to change the value on one sheet. Is there a way to do that in VBA without changing the focus of the active window with Window('name').activate.

I have a lot of values where I have to go back and forth with, and I'd rather try to update the info without changing focus back and forth.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Yes, this is easily done.

Example:
Code:
Sub Change_Value()
Sheets("Sheet2").Range("A1").Value = "Test"
End Sub
 
Upvote 0
Can you post the code you have?

Generally you don't need to select/activate workbooks/worksheets/ranges etc to work with them.

For example this will put X in A1 on Sheet1 in workbook MyWorkbook.
Code:
Workbooks("MyWorkbook.xls").Worksheets("Sheet1").Range("A1") = "X"
 
Upvote 0
Thanks for the suggestion. I won't post my code because it's two different modules, and two different forms a lot of code that isn't very useful to show. Right now it's a form that fills in another form, and I'm adding a billing component to that form. I'll try out the suggestion. I was actually considering saving all pertinent information into an object and then putting all that information into the billing form in one shot instead of going back and forth. I'll try both ways.
 
Upvote 0
Try something similar to this?

Workbooks("Your_wb1.xls").Worksheets("Sheet1").Range("A1")=Workbooks("Your_wb2.xls").Worksheets("Sheet1").Range("A1")
 
Upvote 0
Are you sure it wouldn't be helpful to post the code?

Without seeing it we really are just guessing.:)
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,908
Members
448,532
Latest member
9Kimo3

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