Input Box coding

cheoke

New Member
Joined
Feb 19, 2009
Messages
32
I need a little help figuring out how I can get a certain data range using an input box command. Here is the code I have so far

Code:
Function Getdatarange()
Getdatarange = InputBox("Enter type of data for export")
    Dim SS As Range
    Dim XFMR As Range
    Dim CT As Range
    Dim LC As Range
    Dim wordApp As Object
    Dim fNameAndPath As String
   Set SS = Worksheets("Sheet3").Range("A1:S16")
   Set XFMR = Worksheets("Sheet3").Range("B25:H36")
   Set CT = Worksheets("Sheet3").Range("M21:R24")
   Set LC = Worksheets("Sheet3").Range("M31:R34")
    fNameAndPath = "C:\Documents and Settings\Gerard\My Documents\BOM.doc"
    Set wordApp = CreateObject("Word.Application")
    wordApp.Documents.Open (fNameAndPath)
    wordApp.Visible = True
End Function

When I run the program now I can input a phrase, but nothing is returned. I would like to be able to input Safety Switch(SS) or Transformer(XFMR) into the body of the input box and have the returned range copied and pasted onto the new word file. Can this be accomplished? Thank You in advance
 
Try:

Code:
    Do
        yesno = MsgBox("Do you have more than one range you wish to place on the BOM Sheet?", vbYesNo)
        Select Case yesno
            Case vbYes
                DataRange = InputBox("Enter type of data for export")
                If DataRange = "SS" Then
                    SS.Copy
                ElseIf DataRange = "CT" Then
                    CT.Copy
                ElseIf DataRange = "XFMR" Then
                    XFMR.Copy
                ElseIf DataRange = "LC" Then
                    LC.Copy
                End If
            Case vbNo
                Exit Do
        End Select
        wordApp.Selection.Paste
    Loop
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top