Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. How do I

How do I

Scheduled Pinned Locked Moved Visual Basic
toolshelptutorialquestionlearning
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Matthew Leggett
    wrote on last edited by
    #1

    I need to find out how to do the following: I have a script to do this Ask User for a variable Create a NEW sheet with the variable name I am able to do some of the above however I need to incorporate some error checking to prevent the script failing. wats the best course of action hope this makes sense to someone

    S D 2 Replies Last reply
    0
    • M Matthew Leggett

      I need to find out how to do the following: I have a script to do this Ask User for a variable Create a NEW sheet with the variable name I am able to do some of the above however I need to incorporate some error checking to prevent the script failing. wats the best course of action hope this makes sense to someone

      S Offline
      S Offline
      Steven J Jowett
      wrote on last edited by
      #2

      Is this a question about VB scripting in MS Excel?

      Steve Jowett ------------------------- It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)

      M 1 Reply Last reply
      0
      • S Steven J Jowett

        Is this a question about VB scripting in MS Excel?

        Steve Jowett ------------------------- It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)

        M Offline
        M Offline
        Matthew Leggett
        wrote on last edited by
        #3

        yes it is

        C 1 Reply Last reply
        0
        • M Matthew Leggett

          yes it is

          C Offline
          C Offline
          ChandraRam
          wrote on last edited by
          #4

          Ok - I guess you need to check for 2 things: 1) Check that the user input is valid (not blank, doesnt contain invalid characters...) 2) Check that the name specified does not already exist as another sheet in the workbook where you want to attempt to create the new sheet (Check the Workbook.Sheets collection) HTH

          1 Reply Last reply
          0
          • M Matthew Leggett

            I need to find out how to do the following: I have a script to do this Ask User for a variable Create a NEW sheet with the variable name I am able to do some of the above however I need to incorporate some error checking to prevent the script failing. wats the best course of action hope this makes sense to someone

            D Offline
            D Offline
            Dalek Dave
            wrote on last edited by
            #5

            I used somethng like this recently. In my case I wanted a new sheet consisting only of data of a particular Suppliers account. But you can see the basis of it and adapt as per necessary.

            'request supplier
            Dim RequestedSupplier As String
            RequestedSupplier = Application.InputBox("Enter Supplier Code", "Supplier Selection", , , , , , 2)
            If RequestedSupplier = "" Then End

            'UPPER CASE the RESULT
            RequestedSupplier = UCase(RequestedSupplier)
            'confirm supplier
            MsgBox ("You have Selected : " & RequestedSupplier)
            'create page
            'creates ActNm - Active Sheet name
            Dim ActNm As String
            With ActiveWorkbook.Sheets
            .Add after:=Worksheets(Worksheets.Count)
            End With
            ActNm = ActiveSheet.Name
            On Error Resume Next
            ActiveSheet.Name = RequestedSupplier
            NoName: If Err.Number = 1004 Then ActiveSheet.Name = InputBox("Enter name for New Sheet")
            If ActiveSheet.Name = ActNm Then GoTo NoName
            On Error GoTo 0

            Hope this helps

            ------------------------------------ "I'd rather have a bottle in front of me than a frontal lobotomy" - Bob Monkhouse

            D 1 Reply Last reply
            0
            • D Dalek Dave

              I used somethng like this recently. In my case I wanted a new sheet consisting only of data of a particular Suppliers account. But you can see the basis of it and adapt as per necessary.

              'request supplier
              Dim RequestedSupplier As String
              RequestedSupplier = Application.InputBox("Enter Supplier Code", "Supplier Selection", , , , , , 2)
              If RequestedSupplier = "" Then End

              'UPPER CASE the RESULT
              RequestedSupplier = UCase(RequestedSupplier)
              'confirm supplier
              MsgBox ("You have Selected : " & RequestedSupplier)
              'create page
              'creates ActNm - Active Sheet name
              Dim ActNm As String
              With ActiveWorkbook.Sheets
              .Add after:=Worksheets(Worksheets.Count)
              End With
              ActNm = ActiveSheet.Name
              On Error Resume Next
              ActiveSheet.Name = RequestedSupplier
              NoName: If Err.Number = 1004 Then ActiveSheet.Name = InputBox("Enter name for New Sheet")
              If ActiveSheet.Name = ActNm Then GoTo NoName
              On Error GoTo 0

              Hope this helps

              ------------------------------------ "I'd rather have a bottle in front of me than a frontal lobotomy" - Bob Monkhouse

              D Offline
              D Offline
              Deeprj77
              wrote on last edited by
              #6

              Hi, Please help me to create pdf file from crystal reports with sub reports and parameters? Thanks, Deepa

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups