ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   hide sheet (https://www.excelbanter.com/excel-programming/397421-hide-sheet.html)

geebee

hide sheet
 
hi,

i have some programming in sheet1 like:

range("A1").select
selection.copy
range("C1").select
selection.paste

right now the code only works if i make the code go to the sheet firt like:
sheets("sheet1").select

i would like to know how i can stay on my current sheet_new and have the
code execute without having to actually go to or put focus on sheet1 as made
possible by the sheets("sheet1").select


thanks in advance,
geebee


JW[_2_]

hide sheet
 
Sub foo()
With Sheets("Sheet1")
.Range("A1").Copy
.Range("C1").PasteSpecial xlPasteAll
End With
Application.CutCopyMode = False
End Sub

geebee noSPAMs wrote:
hi,

i have some programming in sheet1 like:

range("A1").select
selection.copy
range("C1").select
selection.paste

right now the code only works if i make the code go to the sheet firt like:
sheets("sheet1").select

i would like to know how i can stay on my current sheet_new and have the
code execute without having to actually go to or put focus on sheet1 as made
possible by the sheets("sheet1").select


thanks in advance,
geebee



FSt1

hide sheet
 
hi,
with the code you have, it assumes that your are talking about the current
sheet. to do something on another sheet, you have to specify which sheets.

Sub copyit()
Activeworkbook.sheets("sheet1").select
ActiveWorkbook.Sheets("sheet2").Range("A1").Copy
ActiveWorkbook.Sheets("sheet2").Range("A2").PasteS pecial xlPasteAll
End Sub

regards
FSt1
"geebee" wrote:

hi,

i have some programming in sheet1 like:

range("A1").select
selection.copy
range("C1").select
selection.paste

right now the code only works if i make the code go to the sheet firt like:
sheets("sheet1").select

i would like to know how i can stay on my current sheet_new and have the
code execute without having to actually go to or put focus on sheet1 as made
possible by the sheets("sheet1").select


thanks in advance,
geebee


Tom Ogilvy

hide sheet
 
You can do it with one command:

with worksheets("Sheet1")
.range("A1").Copy .Range("C1")
End With


--
Regards,
Tom Ogilvy


"geebee" wrote:

hi,

i have some programming in sheet1 like:

range("A1").select
selection.copy
range("C1").select
selection.paste

right now the code only works if i make the code go to the sheet firt like:
sheets("sheet1").select

i would like to know how i can stay on my current sheet_new and have the
code execute without having to actually go to or put focus on sheet1 as made
possible by the sheets("sheet1").select


thanks in advance,
geebee


geebee

hide sheet
 
this is a good way to avoind the sheet apearing during a copy operation, but
what about an operation like programatically hiding a pivot table value?



"Tom Ogilvy" wrote:

You can do it with one command:

with worksheets("Sheet1")
.range("A1").Copy .Range("C1")
End With


--
Regards,
Tom Ogilvy


"geebee" wrote:

hi,

i have some programming in sheet1 like:

range("A1").select
selection.copy
range("C1").select
selection.paste

right now the code only works if i make the code go to the sheet firt like:
sheets("sheet1").select

i would like to know how i can stay on my current sheet_new and have the
code execute without having to actually go to or put focus on sheet1 as made
possible by the sheets("sheet1").select


thanks in advance,
geebee



All times are GMT +1. The time now is 12:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com