Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How do I paste information to hidden worksheets?

I have several Protected and shared workbooks on the network. All are
identical and have hidden worksheets. I have a master that does not have the
worksheets hidden which contains a macro that changes the information in a
name range. The macro works just fine, but when i run the macro it cant find
the sheet indicated in the other workbooks because the sheets are hidden. Is
there a solution with-out having to unprotect the other workbooks?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I paste information to hidden worksheets?

I'm guessing that you're trying to select the hidden sheet (or select a range on
that hidden sheet) first.

You don't need to select a range to work with it:

dim myRng1 as range
dim destcell as range

with worksheets("sheet99")
set myrng1 = .range("a1:x99")
end with

set destcell = worksheets("hidden").range("b27")

myrng1.copy _
destination:=destcell



sir Lancelot wrote:

I have several Protected and shared workbooks on the network. All are
identical and have hidden worksheets. I have a master that does not have the
worksheets hidden which contains a macro that changes the information in a
name range. The macro works just fine, but when i run the macro it cant find
the sheet indicated in the other workbooks because the sheets are hidden. Is
there a solution with-out having to unprotect the other workbooks?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How do I paste information to hidden worksheets?

here is the working macro. It works fine when the worksheets are not hidden.
The problem happens at
Sub File Copy()
Sheets("lookup") and ("Staff_Report") are hidden

Can a code be inserted to unlock the workbook,display the worksheet, run the
macro then relock thr workbook?

Sub aSelectMonth()

' Set module level variable m_selecteddate to month desired

If ActiveCell.Value = "" Then
Exit Sub
End If

If m_selecteddate = "12:00:00 AM" Then
If IsDate(ActiveCell.Value) Then
Let m_selecteddate = ActiveCell
Range("D1").Select
Else: MsgBox "Please select month", vbOKOnly
Exit Sub
End If
Call CopyLOCCodes
End If

' If IsDate(ActiveCell.Value) Then
' Let m_selecteddate = ActiveCell
' Range("D1").Select
' Else: MsgBox "Please select month", vbOKOnly
' Exit Sub
' End If
'
Call CopyLOCCodes

End Sub

Sub CopyLOCCodes()
' Copy Lookup List to a Months Worksheets
' DIM Worksheet file names

Dim filename As String
Dim m_unit As String

Range("LOCCODES").Copy

Let m_unit = ActiveCell.Value

If m_unit = "" Then
Exit Sub
End If

Let filename = m_unit & " " & Format(m_selecteddate, "mmm yy") &
".xls"

ChDrive "I:\"
ChDir "I:\EDO\Staffing\Working Documents\SCHEDULES\" &
Format(m_selecteddate, "mmm")

' ChDrive "Q:\"
' ChDir "Q:\Staffing on 'Mhnoa2UsersGroupEdo' (J)\Working
Documents\SCHEDULES\" & Format(m_selecteddate, "mmm")
Workbooks.Open filename

Windows(filename).Activate

Call FileCopy

Call aSelectMonth

End Sub

Sub FileCopy()
Sheets("Lookup").Select
Range("C2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Sheets("Staff_report").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("A50").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("A100").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("A150").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Sheets("AM").Select

Range("G4").Select

ActiveWorkbook.Save
ActiveWorkbook.Close

Windows("2006 master schedule.xls").Activate
Application.CutCopyMode = False
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate

' Call CopyLOCCodes
End Sub


"Dave Peterson" wrote:

I'm guessing that you're trying to select the hidden sheet (or select a range on
that hidden sheet) first.

You don't need to select a range to work with it:

dim myRng1 as range
dim destcell as range

with worksheets("sheet99")
set myrng1 = .range("a1:x99")
end with

set destcell = worksheets("hidden").range("b27")

myrng1.copy _
destination:=destcell



sir Lancelot wrote:

I have several Protected and shared workbooks on the network. All are
identical and have hidden worksheets. I have a master that does not have the
worksheets hidden which contains a macro that changes the information in a
name range. The macro works just fine, but when i run the macro it cant find
the sheet indicated in the other workbooks because the sheets are hidden. Is
there a solution with-out having to unprotect the other workbooks?


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I paste information to hidden worksheets?

First, naming your sub FileCopy is probably a bad idea.

There's a FileCopy statement in VBA that could cause confusion--maybe not with
excel--but it sure would confuse me. I'd rename it.

I didn't test this, but I'd try this sort of code:

Sub myFileCopy()
Worksheets("Lookup").Range("C2").PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Worksheets("Staff_report").Range("A1").PasteSpecia l _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Worksheets("Staff_report").Range("A50").PasteSpeci al _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Worksheets("Staff_report").Range("A100").PasteSpec ial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Worksheets("Staff_report").Range("A150").PasteSpec ial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

'rest of your original code here.

End Sub

And yes, you can unprotect a workbook, display the worksheet, run the macro,
hide the sheet, reprotect the workbook.

Option Explicit
Sub testme02()
Dim myVisibility As Long
Dim myPWD As String

myPWD = "asdf"

With Workbooks("book1.xls")
.Unprotect Password:=myPWD
myVisibility = .Worksheets("Lookup").Visible
.Worksheets("lookup").Visible = xlSheetVisible
'do the work
MsgBox "do the work!"
.Worksheets("lookup").Visible = myVisibility
.Protect Password:=myPWD
End With

End Sub

(You could get most of this code by recording a macro when you do this
manually.)

But most of the time, there isn't a reason to do things this way. I think most
people find the:

worksheets("Lookup").select
range("a1").select
selection.pastespecial....

much more difficult to read/debug than:

worksheets("lookup").range("a1").pastespecial...

sir Lancelot wrote:

here is the working macro. It works fine when the worksheets are not hidden.
The problem happens at
Sub File Copy()
Sheets("lookup") and ("Staff_Report") are hidden

Can a code be inserted to unlock the workbook,display the worksheet, run the
macro then relock thr workbook?

Sub aSelectMonth()

' Set module level variable m_selecteddate to month desired

If ActiveCell.Value = "" Then
Exit Sub
End If

If m_selecteddate = "12:00:00 AM" Then
If IsDate(ActiveCell.Value) Then
Let m_selecteddate = ActiveCell
Range("D1").Select
Else: MsgBox "Please select month", vbOKOnly
Exit Sub
End If
Call CopyLOCCodes
End If

' If IsDate(ActiveCell.Value) Then
' Let m_selecteddate = ActiveCell
' Range("D1").Select
' Else: MsgBox "Please select month", vbOKOnly
' Exit Sub
' End If
'
Call CopyLOCCodes

End Sub

Sub CopyLOCCodes()
' Copy Lookup List to a Months Worksheets
' DIM Worksheet file names

Dim filename As String
Dim m_unit As String

Range("LOCCODES").Copy

Let m_unit = ActiveCell.Value

If m_unit = "" Then
Exit Sub
End If

Let filename = m_unit & " " & Format(m_selecteddate, "mmm yy") &
".xls"

ChDrive "I:\"
ChDir "I:\EDO\Staffing\Working Documents\SCHEDULES\" &
Format(m_selecteddate, "mmm")

' ChDrive "Q:\"
' ChDir "Q:\Staffing on 'Mhnoa2UsersGroupEdo' (J)\Working
Documents\SCHEDULES\" & Format(m_selecteddate, "mmm")
Workbooks.Open filename

Windows(filename).Activate

Call FileCopy

Call aSelectMonth

End Sub

Sub FileCopy()
Sheets("Lookup").Select
Range("C2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Sheets("Staff_report").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("A50").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("A100").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("A150").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Sheets("AM").Select

Range("G4").Select

ActiveWorkbook.Save
ActiveWorkbook.Close

Windows("2006 master schedule.xls").Activate
Application.CutCopyMode = False
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate

' Call CopyLOCCodes
End Sub

"Dave Peterson" wrote:

I'm guessing that you're trying to select the hidden sheet (or select a range on
that hidden sheet) first.

You don't need to select a range to work with it:

dim myRng1 as range
dim destcell as range

with worksheets("sheet99")
set myrng1 = .range("a1:x99")
end with

set destcell = worksheets("hidden").range("b27")

myrng1.copy _
destination:=destcell



sir Lancelot wrote:

I have several Protected and shared workbooks on the network. All are
identical and have hidden worksheets. I have a master that does not have the
worksheets hidden which contains a macro that changes the information in a
name range. The macro works just fine, but when i run the macro it cant find
the sheet indicated in the other workbooks because the sheets are hidden. Is
there a solution with-out having to unprotect the other workbooks?


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How do I paste information to hidden worksheets?

Thanks

"Dave Peterson" wrote:

First, naming your sub FileCopy is probably a bad idea.

There's a FileCopy statement in VBA that could cause confusion--maybe not with
excel--but it sure would confuse me. I'd rename it.

I didn't test this, but I'd try this sort of code:

Sub myFileCopy()
Worksheets("Lookup").Range("C2").PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Worksheets("Staff_report").Range("A1").PasteSpecia l _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Worksheets("Staff_report").Range("A50").PasteSpeci al _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Worksheets("Staff_report").Range("A100").PasteSpec ial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Worksheets("Staff_report").Range("A150").PasteSpec ial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

'rest of your original code here.

End Sub

And yes, you can unprotect a workbook, display the worksheet, run the macro,
hide the sheet, reprotect the workbook.

Option Explicit
Sub testme02()
Dim myVisibility As Long
Dim myPWD As String

myPWD = "asdf"

With Workbooks("book1.xls")
.Unprotect Password:=myPWD
myVisibility = .Worksheets("Lookup").Visible
.Worksheets("lookup").Visible = xlSheetVisible
'do the work
MsgBox "do the work!"
.Worksheets("lookup").Visible = myVisibility
.Protect Password:=myPWD
End With

End Sub

(You could get most of this code by recording a macro when you do this
manually.)

But most of the time, there isn't a reason to do things this way. I think most
people find the:

worksheets("Lookup").select
range("a1").select
selection.pastespecial....

much more difficult to read/debug than:

worksheets("lookup").range("a1").pastespecial...

sir Lancelot wrote:

here is the working macro. It works fine when the worksheets are not hidden.
The problem happens at
Sub File Copy()
Sheets("lookup") and ("Staff_Report") are hidden

Can a code be inserted to unlock the workbook,display the worksheet, run the
macro then relock thr workbook?

Sub aSelectMonth()

' Set module level variable m_selecteddate to month desired

If ActiveCell.Value = "" Then
Exit Sub
End If

If m_selecteddate = "12:00:00 AM" Then
If IsDate(ActiveCell.Value) Then
Let m_selecteddate = ActiveCell
Range("D1").Select
Else: MsgBox "Please select month", vbOKOnly
Exit Sub
End If
Call CopyLOCCodes
End If

' If IsDate(ActiveCell.Value) Then
' Let m_selecteddate = ActiveCell
' Range("D1").Select
' Else: MsgBox "Please select month", vbOKOnly
' Exit Sub
' End If
'
Call CopyLOCCodes

End Sub

Sub CopyLOCCodes()
' Copy Lookup List to a Months Worksheets
' DIM Worksheet file names

Dim filename As String
Dim m_unit As String

Range("LOCCODES").Copy

Let m_unit = ActiveCell.Value

If m_unit = "" Then
Exit Sub
End If

Let filename = m_unit & " " & Format(m_selecteddate, "mmm yy") &
".xls"

ChDrive "I:\"
ChDir "I:\EDO\Staffing\Working Documents\SCHEDULES\" &
Format(m_selecteddate, "mmm")

' ChDrive "Q:\"
' ChDir "Q:\Staffing on 'Mhnoa2UsersGroupEdo' (J)\Working
Documents\SCHEDULES\" & Format(m_selecteddate, "mmm")
Workbooks.Open filename

Windows(filename).Activate

Call FileCopy

Call aSelectMonth

End Sub

Sub FileCopy()
Sheets("Lookup").Select
Range("C2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Sheets("Staff_report").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("A50").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("A100").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("A150").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Sheets("AM").Select

Range("G4").Select

ActiveWorkbook.Save
ActiveWorkbook.Close

Windows("2006 master schedule.xls").Activate
Application.CutCopyMode = False
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate

' Call CopyLOCCodes
End Sub

"Dave Peterson" wrote:

I'm guessing that you're trying to select the hidden sheet (or select a range on
that hidden sheet) first.

You don't need to select a range to work with it:

dim myRng1 as range
dim destcell as range

with worksheets("sheet99")
set myrng1 = .range("a1:x99")
end with

set destcell = worksheets("hidden").range("b27")

myrng1.copy _
destination:=destcell



sir Lancelot wrote:

I have several Protected and shared workbooks on the network. All are
identical and have hidden worksheets. I have a master that does not have the
worksheets hidden which contains a macro that changes the information in a
name range. The macro works just fine, but when i run the macro it cant find
the sheet indicated in the other workbooks because the sheets are hidden. Is
there a solution with-out having to unprotect the other workbooks?

--

Dave Peterson


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and Paste with hidden columns remaining hidden Pendelfin Excel Discussion (Misc queries) 2 February 26th 09 11:35 AM
copy/paste with hidden rows don't want hidden parts to paste robynne Excel Discussion (Misc queries) 1 September 21st 07 09:23 PM
How do I detect hidden worksheets or hidden data on a worksheet? Alice Excel Discussion (Misc queries) 4 August 24th 06 03:38 AM
Information hidden when I press F2 Gazzr Excel Discussion (Misc queries) 1 April 20th 06 02:24 PM
How do I paste hidden cells and keep them hidden? steven345 Excel Discussion (Misc queries) 0 January 30th 06 05:50 PM


All times are GMT +1. The time now is 11:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"