Select a specific cell after code pasted

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
3,712
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
 

Some videos you may like

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Ramballah

Active Member
Joined
Sep 25, 2018
Messages
255
Office Version
  1. 2019
Platform
  1. Windows
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
 

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
3,712
Office Version
  1. 2007
Platform
  1. Windows
Thanks,
That was one of the many i tried but it errors out with select method of range failed
 

MisterProzilla

Active Member
Joined
Nov 12, 2015
Messages
263
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
 

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
3,712
Office Version
  1. 2007
Platform
  1. Windows
Yes that makes sense now being told.

Worked for me.

Thanks
 

Watch MrExcel Video

Forum statistics

Threads
1,114,519
Messages
5,548,523
Members
410,844
Latest member
Juno49
Top