Select a specific cell after code pasted

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Hi,

Last night i tried a few variations of selecting a specific cell after pasting the code but none worked for me.
I have the code in use below.

Once the code below is run i would like to select cell E7 on both sheets DR SITE & EBAY


Code:
Private Sub CommandButton1_Click()Sheets("Sheet1").Range("P6:U6").Copy Sheets("Sheet1").Range("E6")
Sheets("Sheet1").Range("P7").Copy Sheets("Sheet1").Range("E7")


Sheets("Sheet1").Range("E6:J6").Copy Sheets("DR SITE").Range("E6")
Sheets("Sheet1").Range("E7").Copy Sheets("DR SITE").Range("E7")


Sheets("Sheet1").Range("E6:J6").Copy Sheets("EBAY").Range("E6")
Sheets("Sheet1").Range("E7").Copy Sheets("EBAY").Range("E7")


Sheets("DR SITE").Range("E7").Font.Color = vbWhite
Sheets("DR SITE").Range("E7").Borders.LineStyle = xlNone


Sheets("EBAY").Range("E7").Font.Color = vbWhite
Sheets("EBAY").Range("E7").Borders.LineStyle = xlNone


ActiveWorkbook.Save


End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
hey im definitely not the one who can help you as i myself am new to VBA. However what i see is that you are copying stuff. If you want a cell to be selected then use the Range("CELL").Select command?

Code:
[COLOR=#333333]Sheets("EBAY").Range("E7").Font.Color = vbWhite
[/COLOR][COLOR=#333333]Sheets("EBAY").Range("E7").Borders.LineStyle = xlNone

[/COLOR]Sheets("EBAY").Range("E7").Select
Sheets("DR SITE").Range("E7").Select
 
Upvote 0
Thanks,
That was one of the many i tried but it errors out with select method of range failed
 
Upvote 0
Hi,

As far as I'm aware you need to activate the sheet first - so you can't have Sheet1 active then select a cell in a different sheet. But if you activate the sheet/select the cell in turn in the code, when you go back to those sheets the cell will still be selected.

something like:
Code:
Sheets("DR SITE").Activate
Activesheet.Range("E7").Select

Sheets("EBAY").Activate
Activesheet.Range("E7").Select
 
Upvote 0
Yes that makes sense now being told.

Worked for me.

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,195
Members
453,021
Latest member
pingpong7117

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