Whenever I execute this code, it takes me to the last sheet

SamsonL

New Member
Joined
Jan 30, 2017
Messages
7
Hello,

I have a question of why this process always takes me to the last sheet or to the activated sheet. I have a button for the user to click and select components on the "VFD Cab" Sheet, when it is done, the values will show up on the designated cells, but it takes the user away from the "VFD Cab" sheet and takes me to the "Indexes" sheet. I essentially paste heat loss values into the "Indexes" sheet and a summation of those values are then carried forward to the "VFD Cab" Sheet where the user should get the total heat loss values and stays on the "VFD Cab" sheet.

TIA


If CheckBox1.Value = True Then
Sheets("Heat Tables").Activate
Range("N59").Select
Selection.Copy
Sheets("Indexes").Activate
Range("s17").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


End If
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
It's because you are activating the sheets, try
Code:
If CheckBox1.Value = True Then
Sheets("Heat Tables").Range("N59").Copy
Sheets("Indexes").Range("s17").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
   :=False, Transpose:=False
 
Upvote 0
Code:
  If CheckBox1.Value Then Worksheets("Indexes").Range("S17").Value2 = Worksheets("Heat Tables").Range("N59").Value2
 
Last edited:
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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