Hi everyone,
I'm new to excel VBA/macro etc. I have experience with R and python, but can't use those for my job, sadly.
I am trying to create an 'interactive' Excel file, where a user is asked questions and depending on the answer more questions will be asked.
I have found the following code, which creates a value based on a numeric value in a column:
I adapted it to specify a specific cell and not just a column:
However, If I try to change "Rows(Target.Row).Value" to a string such as "What is the value of Room #X", it fills the entire column range. I have tried to adapt the code but my knowledge is very limited. What would I have to adapt to obtain the following result (images):
->
Thanks in advance
I'm new to excel VBA/macro etc. I have experience with R and python, but can't use those for my job, sadly.
I am trying to create an 'interactive' Excel file, where a user is asked questions and depending on the answer more questions will be asked.
I have found the following code, which creates a value based on a numeric value in a column:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 3/19/2022 6:19:43 AM EDT
If Target.Column = 11 Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
Rows(Target.Row).Offset(1).Resize(Target.Value).Insert
Rows(Target.Row).Offset(1).Resize(Target.Value).Value = Rows(Target.Row).Value
End If
End Sub
I adapted it to specify a specific cell and not just a column:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 3/19/2022 6:19:43 AM EDT
If Target.Column = 11 And Target.Row = 2 Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
Rows(Target.Row).Offset(1).Resize(Target.Value).Insert
Rows(Target.Row).Offset(1).Resize(Target.Value).Value = Rows(Target.Row).Value
End If
End Sub
However, If I try to change "Rows(Target.Row).Value" to a string such as "What is the value of Room #X", it fills the entire column range. I have tried to adapt the code but my knowledge is very limited. What would I have to adapt to obtain the following result (images):
Thanks in advance