Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8391743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:20:36+00:00 2026-06-09T19:20:36+00:00

I have a recorded macro to pull select fields from a web service, the

  • 0

I have a recorded macro to pull select fields from a web service, the URL is something like http://xxxx.com/reportviewer.aspx?ids=123456789012
I would like to prompt the user to input that number as a variable and have the number be passed to the 2 locations were that number is used in the macro.

I know that i have to create another macro to have the user input a value for after that I’m unsure of how pass that along to be filled in the correct location?

Here is my code so far

Sub Macro2()
 '
' Macro2 Macro
'
' Keyboard Shortcut: Ctrl+r
'
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://xxxx.com/reportviewer.aspx?ids=123456789012", _
        Destination:=Range("$A$1"))
        .Name = "reportviewer.aspx?ids=123456789012"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "30,33,37,38,46"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
End Sub
    Range("A2").Select
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:20:38+00:00Added an answer on June 9, 2026 at 7:20 pm

    You can use InputBox to collect the user’s input.
    After collecting, you can test their input before continuing to execute the code.
    here’s the input/validation example:

    '-store user input in 'sUserInput' variable
    Dim sUserInput As String
    sUserInput = InputBox("Enter Number:", "Collect User Input")
    
    'test input before continuing to validate the input
    If Not (Len(sUserInput) > 0 And IsNumeric(sUserInput)) Then
        MsgBox "Input not valid, code aborted.", vbCritical
        Exit Sub
    End If
    

    Your code can reference the variable by refering to the sUserInput here’s a complete version:

    Sub Macro2()
     '
    ' Macro2 Macro
    '
    ' Keyboard Shortcut: Ctrl+r
    '
        '-store user input in 'sUserInput' variable
        Dim sUserInput As String
        sUserInput = InputBox("Enter Number:", "Collect User Input")
    
        'test input before continuing to validate the input
        If Not (Len(sUserInput) > 0 And IsNumeric(sUserInput)) Then
            MsgBox "Input not valid, code aborted.", vbCritical
            Exit Sub
        End If
    
        With ActiveSheet.QueryTables.Add(Connection:= _
            "URL;http://network.construction.com/reportviewer.aspx?ids=" & sUserInput, _
            Destination:=Range("$A$1"))
            .Name = "reportviewer.aspx?ids=" & sUserInput
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .WebSelectionType = xlSpecifiedTables
            .WebFormatting = xlWebFormattingNone
            .WebTables = "30,33,37,38,46"
            .WebPreFormattedTextToColumns = True
            .WebConsecutiveDelimitersAsOne = True
            .WebSingleBlockTextImport = False
            .WebDisableDateRecognition = False
            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
        End With
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recorded a macro with me selecting a project and removing it from
A few test scenarios have been recorded using CodedUI test template for my web
I have DateFirstStarted and DateEnded fields in the database. Date values are recorded as
I have recorded this macro. It's for inserting a chart. How can I create
Suppose that I have recorded a long macro with many commands and special characters.
I have recorded live video from the camera using AVCaptureVideoDataOuput and AVAssetWriter but the
I have recorded real-time stock quotes in an SQL database with fields Id ,
I have a file with a bunch of lines. I have recorded a macro
I have recorded an array[1024] of data from my mic on my Android phone,
I have app in which i have recorded sound files i want that i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.