+ Reply to Thread
Results 1 to 3 of 3

Printing my form Having multiple sheets data base

  1. #1
    Registered User
    Join Date
    08-04-2016
    Location
    QATAR
    MS-Off Ver
    2013
    Posts
    3

    Printing my form Having multiple sheets data base

    Hello everyone.

    Can someone modify my code below my data is only working on 1 sheet and what I wanted now is to array and add another sheet on my code.

    Private Sub CommandButton1_Click()
    ActiveWindow.SelectedSheets.PrintPreview
    End Sub

    Private Sub CommandButton2_Click()
    Dim ws As Worksheet
    Dim LastRow As Long
    Dim Rng As Range

    Set ws = Sheet2

    With ws
    LastRow = .Cells(Rows.Count, "A").End(xlUp).Row

    For Each Rng In .Range("A2:A" & LastRow).SpecialCells(xlCellTypeVisible)
    Sheet1.Range("J8") = Rng
    ActiveWindow.SelectedSheets.PrintPreview
    Next
    End With

    End Sub

    Private Sub Worksheet_Activate()
    Dim ws As Worksheet

    Set ws = Sheet2

    With ws

    LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
    End With

    Sheet1.CommandButton2.Caption = "Print All " & _
    WorksheetFunction.Subtotal(3, Sheet2.Range("A2:A" & LastRow)) & _
    " Records"


    Dim NameAry() As Variant
    Dim A As Long
    With ws

    For A = 2 To LastRow
    ReDim Preserve NameAry(A)
    NameAry(A) = Replace(.Range("P" & A), ",", " - ")
    Next
    End With

    With Sheet1.Range("J8").Validation
    .Delete
    .Add xlValidateList, , , Join(NameAry, ",")
    Application.Calculate
    End With
    End Sub

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: Printing my form Having multiple sheets data base

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    AA CodeTags.jpg

  3. #3
    Registered User
    Join Date
    08-04-2016
    Location
    QATAR
    MS-Off Ver
    2013
    Posts
    3

    Re: Printing my form Having multiple sheets data base

    davesexcel on my sheet1 is my payslip form with vlookup on sheet2 as my data base now I want to add on sheet3 as my data base as well can someone modify my code below so that the data that will validate will pull from both sheet2 and sheet3. Thanks a lot

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Data Entry Form with multiple sheets
    By nimesh29 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2015, 01:04 PM
  2. Use a form to Popualte a Data Base
    By Wouldsman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2014, 09:22 AM
  3. complete data base from form
    By Wouldsman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-24-2014, 10:18 AM
  4. Web form access data base
    By neeraj_logani in forum Access Tables & Databases
    Replies: 1
    Last Post: 09-24-2012, 04:17 PM
  5. Populating multiple sheets from a data form
    By Juli in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-03-2012, 02:45 PM
  6. Multiple users with single form and central data base using VBA for Excel
    By NKOTB_VBA in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2011, 07:59 AM
  7. Printing multiple sheets with different data
    By Gaz via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2005, 05:25 PM

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