+ Reply to Thread
Results 1 to 11 of 11

vba code for master sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    10-03-2012
    Location
    oslo
    MS-Off Ver
    Excel 2010
    Posts
    16

    vba code for master sheet

    Hi guys,

    I have a masterworkbook that consolidates data from 50 different workbooks via vba. The thing is that in each of the 50 workbooks there are check boxes on three sheets. Is it possible to write a code in the existing masterWB that can ask for and turn on/off these checkboxes? My original code is:

    Sub Knapp1_Klikk()
    
    Dim fPATH As String, fNAME As String, NR As Long
    Dim wbDATA As Workbook, wsMASTER As Worksheet
    
    Set wsMASTER = ThisWorkbook.Sheets("databank_fvp") 'edit this to the name of the master sheet
    NR = wsMASTER.Range("A" & Rows.Count).End(xlUp).Row + 1 'next empty row on the master sheet
    
    fPATH = "\\sgm434\avdelinger2$\CA\RL\Stab RL\NRL Forretningsteam\FVP\12.06.2013\FT\" 'path to all files
    fNAME = Dir(fPATH & "*fvp*.xls*") 'get the first filename from the folder
    
    Do While Len(fNAME) > 0 'process one file at a time til no more filenames
    Set wbDATA = Workbooks.Open(fPATH & fNAME) 'open the found file
    With wbDATA.Sheets("databank").Range("2:74") 'copies pax & atm
        wsMASTER.Range("A" & NR).Resize(73, 1).EntireRow.Value = .Value
    
    End With
    
    wbDATA.Close False 'close the found file
    NR = wsMASTER.Range("A" & Rows.Count).End(xlUp).Row + 1 'next empty row on the master sheet
    fNAME = Dir 'get the next filename
    Loop
    
    End Sub

  2. #2
    Registered User
    Join Date
    04-17-2013
    Location
    Bucuresti
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: vba code for master sheet

    Hi,

    My proposal is ...


    Sub Knapp1_Klikk()

    Dim fPATH As String, fNAME As String, NR As Long
    Dim wbDATA As Workbook, wsMASTER As Worksheet

    Set wsMASTER = ThisWorkbook.Sheets("databank_fvp") 'edit this to the name of the master sheet
    NR = wsMASTER.Range("A" & Rows.Count).End(xlUp).Row + 1 'next empty row on the master sheet

    fPATH = "\\sgm434\avdelinger2$\CA\RL\Stab RL\NRL Forretningsteam\FVP\12.06.2013\FT\" 'path to all files
    fNAME = Dir(fPATH & "\*fvp*.xls*") 'get the first filename from the folder

    Do While Len(fNAME) > 0 'process one file at a time til no more filenames
    Set wbDATA = Workbooks.Open(fPATH & "\" & fNAME) 'open the found file
    With wbDATA.Sheets("databank").Range("2:74") 'copies pax & atm
    wsMASTER.Range("A" & NR).Resize(73, 1).EntireRow.Value = .Value

    End With

    wbDATA.Close False 'close the found file
    NR = wsMASTER.Range("A" & Rows.Count).End(xlUp).Row + 1 'next empty row on the master sheet
    fNAME = Dir 'get the next filename
    Loop

    End Sub

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: vba code for master sheet

    Ovidis,
    Please use code tags with your code.

  4. #4
    Registered User
    Join Date
    04-17-2013
    Location
    Bucuresti
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: vba code for master sheet

    Hi AB33,

    Sorry, but I answered the request just as it was posted (how else would I have?)

    P.S. I am "ovidius", but this is not a problem.

    Ovidiu

  5. #5
    Registered User
    Join Date
    04-17-2013
    Location
    Bucuresti
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: vba code for master sheet

    Delete double message.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: vba code for master sheet

    ovidius,

    Sorry for misspelling your name!

    Look at OP's code. It is wrapped with a code. It is difficult to read a code with out being wrapped. Please read form's rule.

  7. #7
    Registered User
    Join Date
    04-17-2013
    Location
    Bucuresti
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: vba code for master sheet

    Ok AB33, I read, but I still do not understand what the problem was posting my response to that request.

    Thanks.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: vba code for master sheet

    ovidius,
    You still do not get!
    If he had bothered to read form's rule, he would have wrapped your code. One of the rules says: When you post a code, you should use code tags. If you look at the code you posted, it does not have a code tag.
    I know you are new to the forum and had tried to politely re-mind you.

  9. #9
    Registered User
    Join Date
    04-17-2013
    Location
    Bucuresti
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: vba code for master sheet

    My problem is: how can I use code tags

    Thanks for all,
    Ovidiu

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: vba code for master sheet

    The form's rule also says if you need any help you should contact the moderators.
    While you are at your code, click edit, then highlight (Select) your code(All lines) and click the # sign which appears on the quick Reply sub menu. The quick reply menu is on this page, down the bottom.

    OR

    [code]

    your code

    [code]

  11. #11
    Registered User
    Join Date
    04-17-2013
    Location
    Bucuresti
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: vba code for master sheet

    Thanks very much AB33.

    Regards

+ 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