adding conditional rows

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, I want to be able to have rows/cells generated with a certain text
based on the answer given by a user.
For example, My question in a cell could be "how many groups have you made?".
Now to this if the user answers "3" then I would want three cells below to
ask "what is the name of your first group", "what is the name of your second
group" and so on. Based on this further questions could be asked.
 
As a astarter

Sub Macro1()
Dim ans
Dim i As Long
Dim sName As String

ans = InputBox("How many groups have you made")
If ans <> "" Then
ActiveCell.Offset(1, 0).Resize(3).Insert
For i = 1 To ans
sName = InputBox("What is the name of group #" & i)
ActiveCell.Offset(i, 0).Value = sName
Next i
End If

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Hello Bob,
Can I do this without the VB? I dont know how to program macros or any form
of VB. I was looking more towards understanding the concept and then
applying. If there is no way then I would try and understand the solution
that you've provided.
 
Not really. You might be able to get some way with conditional
formulae/formatting, but not for the sort of flexibility that you seek.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
thank you bob, your help was indeed very useful. Now could you pls tell me,
what reading material should I refer to, to understand programming macros?
 
Dear Bob,

In the solution provided by you, how do I assign a perticular cell to
capture/store the user inputs from the questions answered in the inputbox

Regards,
Deepak
 
If I properly understand you, Bob provided that in his first post
another idea

range("a1").value=inputbox("your question")
 
Deepak,

Do you understand how to use variables? I ask as I showed you that first
post up, but I think you may not have understood.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top