Please Help

Kmk1605tigre69

New Member
Joined
May 9, 2019
Messages
5
Hi! I’m very new to Visual Basic in Excel and was wondering if anyone would be able to help? I want to be able to enter any number into a text box and click a button that says “Generate.” Once user does this, excel will bring up number of cells in column based on value inputted into text box. Is this possible?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You said:
and click a button that says “Generate.”

Do you mean a Activex Command Button

And are you saying when you made the Button you entered "Generate" as The Button Text?

And you said:
excel will bring up number of cells in column based on value inputted into text box

What does bring up mean


Give us a exact example of what you want. And what column


We always need specific details.
<strike>
</strike>
 
Upvote 0
Command button as in one created in Visual Basic. Text of button is Generate. Let’s say user types 5 in the text box and clicks Generate command button..action would bring up cells A2 through A6.
 
Upvote 0
Still do not understand this:

action would bring up cells A2 through A6.

What does bring up mean?
 
Upvote 0
Your not telling me what
call up means

Call up ???

bring up ???????


 
Upvote 0
Try this:
Assuming your Textbox is named TextBox1

Code:
Private Sub CommandButton1_Click()
'Modified  5/9/2019  10:39:28 PM  EDT
Dim r As Range
Dim ans As String
Dim n As Long
n = ActiveSheet.TextBox1.Value
For Each r In Cells(2, 1).Resize(n)
    ans = ans & r.Value & vbNewLine
Next
MsgBox ans
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,817
Messages
6,121,717
Members
449,050
Latest member
MiguekHeka

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