Question to input a value into a pop up box

largeselection

Active Member
Joined
Aug 4, 2008
Messages
358
I have two values that I want to paste into a template after I've pasted the template into a new worksheet. Let me try and explain clearly...

In the macro I have now it opens a specific workbook and copies a template, then pastes it into the new workbook that I am working on.

I would like to make 2 changes in the template (as those values will change since they are date and time). So I would like to put in code in the macro so that it prompts me for the date and time in the beginning and then when it pastes the template in the new sheet it will change the two cells I needed changed to the responses I put into the pop up box. Here's the intro code that I have
'

'
' Keyboard Shortcut: Ctrl+Shift+M
'
Dim MyFile As Workbook

Set MyFile = ActiveWorkbook
Dim wsheet As Worksheet
For Each wsheet In ActiveWorkbook.Worksheets
Dim Response As Long
Response = InputBox("Today's Date...")

Then I have

Worksheets("Sheet1").Cells(2, 21).Value = Response

So what I was trying to do here is have a box pop up and ask me for "today's date" then i would put it in and then it would paste the template in the new sheet and in the cell "U2" (which is 2,21 I think) it would paste my response.

I also need to set this up so that it prompts me for the answer for to similar questions and pastes my response in X2 (2,24) and Z2 (2,26). So total it will prompt me for 3 questions and then paste my responses into U,X, and Z respectively.

Thanks again in advance for all your suggestion and coaching...
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I think somethign like this is what your wanting...if not, can you clarify?

Code:
Sub Macro1()
    Dim MyFile As Workbook
    Dim wsheet As Worksheet
    Dim Response As Date
    Dim Q2 As String
    Dim Q3 As String
    Set MyFile = ActiveWorkbook
        Response = InputBox("Today's Date...", , Date)
        Q2 = InputBox("A question")
        Q3 = InputBox("Another question")
        For Each wsheet In MyFile.Worksheets
            wsheet.Activate
            [U2] = Response
            [X2] = Q2
            [Z2] = Q3
        Next
End Sub

Edit: added wsheet.activate
 
Last edited:
Upvote 0
Code:
        For Each wsheet In MyFile.Worksheets
            wsheet.Activate
            [U2] = Response
            [X2] = Q2
            [Z2] = Q3
        Next

or you could do this instead...probably better

Code:
        For Each wsheet In MyFile.Worksheets
            Worksheets(wsheet.Name).Cells(2, 21).Value = Response
            Worksheets(wsheet.Name).Cells(2, 24).Value = Q2
            Worksheets(wsheet.Name).Cells(2, 26).Value = Q3
        Next
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

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