+ Reply to Thread
Results 1 to 6 of 6

Creating VBA Button to Do Three Operations Simialtaniously

Hybrid View

djc123 Creating VBA Button to Do... 12-20-2018, 04:25 AM
aarona Re: Creating VBA Button to Do... 12-20-2018, 04:33 AM
aarona Re: Creating VBA Button to Do... 12-20-2018, 04:35 AM
BadlySpelledBuoy Re: Creating VBA Button to Do... 12-20-2018, 04:35 AM
djc123 Re: Creating VBA Button to Do... 12-20-2018, 04:45 AM
BadlySpelledBuoy Re: Creating VBA Button to Do... 12-20-2018, 04:52 AM
  1. #1
    Registered User
    Join Date
    12-18-2018
    Location
    Phuket, Thailand
    MS-Off Ver
    Windows 11 - MS Office 365
    Posts
    88

    Unhappy Creating VBA Button to Do Three Operations Simialtaniously

    Hi all,

    Please note - I am a complete novice and I have been trying to get my head around this for a few days, with little success.

    I want a button/check box/toggle box/I don't care! to do three tasks at the same time.
    - The button will be on Sheet1 "CONTROL CENTER"
    - I want Sheet Sheet4 "Thai Menu" to hide
    - I want column C, P, AC & AP on Sheet16 "Menu-MASTER" to hide
    - I want columns C, P, AC, AP, BC, BP, CC & CP on Sheet17 "Options-MASTER" to hide

    I am using Excel 2016 so VBA is one way to do this. This sheet will be sent to customers for them to complete, if VBA buttons are not supported on older version of Excel I need an alternative option (perhaps Javascript or other, please advise).

    I really need this is all spelt out to me from how to add the button to how to add the code. If you are able to do it in your own Excel document I should be able to copy it over and figure it out from there.

    Thanks for any help in advance, I'm sure there's a whizz out there that can complete this in two minutes!

    Danny

  2. #2
    Forum Contributor
    Join Date
    06-07-2016
    Location
    Manila
    MS-Off Ver
    365
    Posts
    292

    Re: Creating VBA Button to Do Three Operations Simialtaniously

    Sub Button()
    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Dim ws3 As Worksheet
    
        Set ws1 = Worksheets("Thai Menu")
        Set ws2 = Worksheets("Menu-Master")
        Set ws3 = Worksheets("Options-Master")
        
        
        ws1.Visible = xlSheetHidden
        ws2.Columns("C").EntireColumn.Hidden = True
        ws2.Columns("P").EntireColumn.Hidden = True
        ws2.Columns("AC").EntireColumn.Hidden = True
        ws2.Columns("AP").EntireColumn.Hidden = True
        
        ws3.Columns("C").EntireColumn.Hidden = True
        ws3.Columns("P").EntireColumn.Hidden = True
        ws3.Columns("AC").EntireColumn.Hidden = True
        ws3.Columns("AP").EntireColumn.Hidden = True
        ws3.Columns("BC").EntireColumn.Hidden = True
        ws3.Columns("BP").EntireColumn.Hidden = True
        ws3.Columns("CC").EntireColumn.Hidden = True
        ws3.Columns("CP").EntireColumn.Hidden = True
        
        
        
        
    End Sub

  3. #3
    Forum Contributor
    Join Date
    06-07-2016
    Location
    Manila
    MS-Off Ver
    365
    Posts
    292

    Re: Creating VBA Button to Do Three Operations Simialtaniously

    See attached file.
    Attached Files Attached Files

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,916

    Re: Creating VBA Button to Do Three Operations Simialtaniously

    Or this:
    Private Sub CommandButton1_Click()
        With ThisWorkbook
            .Sheets("Thai Menu").Visible = False
            .Sheets("Menu-MASTER").Range("C1,P1,AC1").EntireColumn.Hidden = True
            .Sheets("Options-MASTER").Range("C1,P1,AC1,BC1,BP1,CC1,CP1").EntireColumn.Hidden = True
        End With
    End Sub
    BSB
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-18-2018
    Location
    Phuket, Thailand
    MS-Off Ver
    Windows 11 - MS Office 365
    Posts
    88

    Re: Creating VBA Button to Do Three Operations Simialtaniously

    Hey guys,

    Thanks for that.

    Those buttons only make them hide, how about the same button making the opposite happen (appear).

    Danny

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,916

    Re: Creating VBA Button to Do Three Operations Simialtaniously

    Try this version with a ToggleButton:
    Private Sub ToggleButton1_Change()
        With ThisWorkbook
            If ToggleButton1 = True Then
                .Sheets("Thai Menu").Visible = False
                .Sheets("Menu-MASTER").Range("C1,P1,AC1").EntireColumn.Hidden = True
                .Sheets("Options-MASTER").Range("C1,P1,AC1,BC1,BP1,CC1,CP1").EntireColumn.Hidden = True
                ToggleButton1.Caption = "Unhide"
            Else
                .Sheets("Thai Menu").Visible = True
                .Sheets("Menu-MASTER").Range("C1,P1,AC1").EntireColumn.Hidden = False
                .Sheets("Options-MASTER").Range("C1,P1,AC1,BC1,BP1,CC1,CP1").EntireColumn.Hidden = False
                ToggleButton1.Caption = "Hide"
            End If
        End With
    End Sub
    BSB
    Attached Files Attached Files

+ 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. Creating VBA Button to Do Two Operations Simultaneously
    By djc123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2018, 07:39 AM
  2. [SOLVED] Button to calculate multiple math operations in a userform, at once
    By Alex Piotto in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-26-2018, 05:56 AM
  3. [SOLVED] Help creating a macro button
    By glenlaw in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-15-2013, 12:10 AM
  4. Creating a simple button
    By jaywizz in forum Excel General
    Replies: 2
    Last Post: 08-03-2009, 09:42 AM
  5. Creating a Macro Button
    By Newton1234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-12-2008, 11:46 AM
  6. Creating a Print Button
    By william4444 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 06-22-2006, 02:33 AM
  7. Creating a custom button...
    By andyd2k in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-15-2005, 04:26 PM

Tags for this Thread

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