Avatar of Bright01
Bright01
Flag for United States of America asked on

Adding a new way to input Data into Excel

EE Pros...... HAPPY NEW YEAR!

I am looking for a easy way for users to input some simple information.  I've attached a sample of what I'm looking for.  Basically, it's taking perhaps a Form (open to any approach) and have the ability to input two variables (Amount per month and Number of Months) and have the product placed in a particular cell.  The Form or input capability must be triggered by some action.... I was thinking about a triple click on the specific cell for the Form to come up and then a click on the Form to extract it.  If the User doesn't want to use the Form (i.e. they put the amount in themselves, they can put it in without firing the Form up.

Got it?  

Questions, ideas or a solution is welcome!

Thank you in advance,

B.
Adding-a-input-capability.xlsm
Microsoft ExcelVBA

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon
Excel amusant

Hi Bright01, Happy New Year!

Do you want something like this? Please see attached. Click on the macro button fill the number of months and value per month and you will get the desired output in Cell f7.
Adding-a-input-capability.xlsm
Excel amusant

Or these two

Whenever cell F7 is selected the Macro will automatically runs. or Attachment (V3) Whenever cell F7 is selected the a msgbox appears asking whether you want to run the macro or not.

See attached examples. Select Cell F7 and follow the macro.
Adding-a-input-capability--v2-.xlsm
Adding-a-input-capability--v3-.xlsm
Bill Prew

Not sure if I understood what you wanted, but give this a try.

If you just click into the two cells you mentioned, you can type a value.  If you double click into the cells, then an input form will pop up and values can be entered, and the result placed in the cell when OKAY is pressed.

I didn't go crazy with formatting or error checking, but this should give you some ideas.

~bp
EE28913525.xlsm
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Bright01

ASKER
Bill, will take a look.  Excel amusant,  #2 is close.  You should be able to enter your own number in the cell (Cell F7) OR, by either clicking or hovering, have the question form come up.  Can you combine the input data into the form so that you can put both $ / Mo. And # / Mo. In the same box?  Then the amount is placed in the same box....F7.  And after the data is entered the box can close. The example below was to show what it looked like once the data was entered.
Adding-a-input-capability--v2-.xlsm
Bright01

ASKER
Bill, closest yet!  That's what I'm looking for.  Doubleclick on the cell and up comes the box to enter the simple data.  The math then puts the product back into the box.  Can you set it up so that I can do multiple cells?  + error checking?  Is it contained in the WS or a module?  Better in the specific worksheet since I have my production version in multiple WSs and wouldn't need this capability anywhere else.
Bill Prew

It does currently support multiple cells, take a look at the VBA code associated with Sheet1 (also included below).  Notice the check for which cells to enable this on.

There is some basic editing for numeric values, what additional editing would make sense.  That can be added to the btnOkay_Click event in the VBA code associated with the button in the frmData form (also included below).

That is all the code that was needed, and the form itself.  The form and it's VBA resides in the Workbook, while the triggering logic lives in the VBA associated with Sheet1.

Sheet1 VBA code
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   If Target.Address = "$F$7" Or Target.Address = "$F$20" Then
      frmData.Show
   End If
End Sub

Open in new window

frmData VBA code
Private Sub btnOkay_Click()
   With Me
      If .txtDollars <> vbNullString And .txtNumber <> vbNullString Then
         ActiveCell.Value = .txtDollars.Value * .txtNumber
      End If
      .Hide
   End With
End Sub

Private Sub txtDollars_Change()
    NumberEdit
End Sub

Private Sub txtNumber_Change()
    NumberEdit
End Sub

Private Sub NumberEdit()
    If TypeName(Me.ActiveControl) = "TextBox" Then
        With Me.ActiveControl
            If Not IsNumeric(.Value) And .Value <> vbNullString Then
                MsgBox "Only numbers allowed"
                .Value = vbNullString
            End If
        End With
    End If
End Sub

Open in new window

~bp
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Excel amusant

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Bright01

ASKER
Looking at both of these great examples......

Bill, if I wanted to add say, 5 cells that have this capability, how would I change this part of the code (such as what you have put here for F7 and F20)?  In other words, what if I have a list of these cells?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   If Target.Address = "$F$7" Or Target.Address = "$F$20" Then
      DataEntrySaaS.Show
   End If

BTW; I changed the name of the Form.

B.
ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Bill Prew

Another approach would be to place all the cells you want this to occur on into a named range, and then test for that in the double click event.  Here's an example of that, testing against the named range "Popup".

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   If Not (Application.Intersect(Target, Range("Popup")) Is Nothing) Then
         frmData.Show
   End If
End Sub

Open in new window

~bp
Bright01

ASKER
But when using "range names" the cells have to be contiguous right?

B.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Bright01

ASKER
Hey guys!  Great job.  Both solutions worked; however, I can only use one.  What's really great when you guys do this, I really learn a lot.

Again, much thanks and happy 2016.

B.
Bill Prew

Thanks for the feedback, glad that was helpful.

No, cells in ranges do not have to be contiguous, they can just be a list of cells.  For example for testing I created the range that looked this way.

sshot-71.png~bp