+ Reply to Thread
Results 1 to 10 of 10

How to work with a hidden sheet?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    How to work with a hidden sheet?

    Hello

    I am doing a macro that copies data in an intermediate sheet that I want to be hidden..
    My macro works when the sheet is not hidden but once hidden it doesn't work...
    Could somebody help me?

    Here is my code

    Sub copydata()
    
    Dim lngCounter As Long
    Dim lngMax As Long
    Dim lngCol As Long
    
    'copier de la sheet1 a la sheet2, on copie en valeurs
    Worksheets("Sheet2").Cells.ClearContents
    Worksheets("Sheet3").Cells.ClearContents
    
    Worksheets("Sheet1").Range("zoneselect").Copy
    Sheets("Sheet2").Select
        Range("B1").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    
    ' On enleve les blancs entre la sheet 2 à la sheet3
    '
    '
        Worksheets("Sheet2").Range("A1:BB1").Select
        Selection.Copy
        Sheets("Sheet3").Select
        Range("B1").Select
        ActiveSheet.Paste
        Selection.SpecialCells(xlCellTypeBlanks).Select
        Application.CutCopyMode = False
        Selection.Delete shift:=xlToLeft
    
    Sheets("Sheet2").Select
    'On selectionne l'action qui a le plus de dates pour la copier dans la sheet3
    
    
    For lngCounter = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
      If InStr(1, Cells(1, lngCounter).Value, "FP") > 0 Then
        If Cells(Rows.Count, lngCounter).End(xlUp).Row > lngMax Then
          lngMax = Cells(Rows.Count, lngCounter).End(xlUp).Row
          lngCol = lngCounter
        End If
      End If
    Next lngCounter
    'MsgBox "Greatest length is " & lngMax & " beneath Range " & Cells(1, lngCol).Address(0, 0)
    With Worksheets("Sheet2").Range(Cells(2, lngCol), Cells(lngMax, lngCol)).Select
    End With
        Selection.Copy
        Worksheets("Sheet3").Select
        Range("A2").Select
    ActiveSheet.Paste
    
    'retour a la sheet1
    Sheets("Sheet1").Select
    
    End Sub


    Best regards

    R

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: How to work with a hidden sheet?

    Cross-post http://www.ozgrid.com/forum/showthread.php?t=172491

  3. #3
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Re: How to work with a hidden sheet?

    is it forbidden?

  4. #4
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Re: How to work with a hidden sheet?

    Sorry about that
    anybody knows how to solve this?

  5. #5
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Re: How to work with a hidden sheet?

    Sorry about that
    anybody knows how to solve this?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    Don't use Select/Selection
    If posting code please use code tags, see here.

  7. #7
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Re: How to work with a hidden sheet?

    THen what should I use?

    Thanks for your help! :-)

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: How to work with a hidden sheet?

    Here's an example.

    This:
    Worksheets("Sheet1").Range("zoneselect").Copy
    Sheets("Sheet2").Select
        Range("B1").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Can be written like this.
    Worksheets("Sheet1").Range("zoneselect").Copy
    Sheets("Sheet2").Range("B1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats

  9. #9
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Re: How to work with a hidden sheet?

    I'm succeeding little by little :-)

    but what should I put in this case?

    Sheets("Sheet2").Select
    
    For lngCounter = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
      If InStr(1, Cells(1, lngCounter).Value, "FP") > 0 Then
        If Cells(Rows.Count, lngCounter).End(xlUp).Row > lngMax Then
          lngMax = Cells(Rows.Count, lngCounter).End(xlUp).Row
          lngCol = lngCounter
        End If
      End If
    Next lngCounter
    
    With Worksheets("Sheet2").Range(Cells(2, lngCol), Cells(lngMax, lngCol)).Select
    End With
        Selection.Copy
        Worksheets("Sheet3").Select
        Range("A2").Select
    ActiveSheet.Paste

  10. #10
    Forum Contributor
    Join Date
    10-18-2012
    Location
    ardeduck schools
    MS-Off Ver
    Excel 2003
    Posts
    100

    Re: How to work with a hidden sheet?

    ok I will try and let you know!
    Thanks a lot!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1