Results 1 to 3 of 3

Declaring Strings

Threaded View

  1. #1
    Registered User
    Join Date
    06-18-2015
    Location
    UK
    MS-Off Ver
    2016
    Posts
    6

    Declaring Strings

    Hi All

    I'm fairly new to VBA, but have written some code so that when a checkbox is ticked an inputbox appears, forces a user to enter data, then that input data goes into a specific cell. everything worked fine on my first one. when I try to duplicate the same thing for a different checkbox, a different inputbox and different specific cell I get an error that says
    Compile error: Duplicate declaration in current scope.

    This is my code for the one that works;

    Private Sub CheckBoxWallType_Click()
    
    If CheckBoxWallType.Value = True Then
    
    Dim WallType As String
    Sheets("FS").Rows("9:9").EntireRow.Hidden = False
    WallType = InputBox("Specify another wall type", "Wall Type")
    
        If Len(WallType) = 0 Then 'checks if user entry has been made
            
            MsgBox "You have not entered a wall type. The checkbox has been unchecked", vbInformation, "You must enter a wall type" 'if no entry an error message displays
        
            Range("B9").Value = "" 'Cell B9 is left blank
        
            CheckBoxWallType.Value = False 'checkbox reverts back to unchecked
            Sheets("FS").Rows("9:9").EntireRow.Hidden = True
        End If
    
    Range("B9").Value = WallType 'Cell B9 = user entry
    
    Else
    
    Range("B9:C9").Value = ""
    Sheets("FS").Rows("9:9").EntireRow.Hidden = True
    
    End If
    
    End Sub
    [/I]and this is the code for the one that doesn't;

    Private Sub WallFinish_Click()
    If WallFinish.Value = True Then
    
    Dim WallFinish As String
    Sheets("FS").Rows("16:16").EntireRow.Hidden = False
    WallFinish = InputBox("Specify another wall finish", "Wall Finish")
    
        If Len(WallFinish) = 0 Then 'checks if user entry has been made
            
            MsgBox "You have not entered a wall finish. The checkbox has been unchecked", vbInformation, "You must enter a wall finish" 'if no entry an error message displays
        
            Range("B16").Value = "" 'Cell B16 is left blank
        
            WallFinish.Value = False 'checkbox reverts back to unchecked
            Sheets("FS").Rows("16:16").EntireRow.Hidden = True
        End If
    
    Range("B16").Value = WallFinish 'Cell B16 = user entry
    
    Else
    
    Range("B16:C16").Value = ""
    Sheets("FS").Rows("16:16").EntireRow.Hidden = True
    
    End If
    End Sub
    Please help....many thanks
    Last edited by babb101; 08-17-2016 at 03:01 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to Delete only Alpha Strings but not Alphanumeric or Numeric Strings in a Cell
    By papageorgio in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2016, 06:55 AM
  2. [SOLVED] Declaring and Initializing an Array of Strings
    By Akki4228 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-30-2013, 06:11 PM
  3. [SOLVED] Loop through strings stop when strings change and start looping in the next column...?
    By Prexcel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-18-2013, 03:31 AM
  4. Replies: 1
    Last Post: 08-13-2013, 08:32 AM
  5. Replies: 2
    Last Post: 03-07-2013, 02:34 AM
  6. Replies: 9
    Last Post: 12-21-2012, 04:18 AM
  7. Replies: 5
    Last Post: 02-15-2012, 09:57 AM

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