VB help

Please can you help with the attached file.

Rather than select the next cell after B14, using the command button. I want the form to open on whatever cell happens to be selected in column B.

Secondly, If data already exists on that line, is it possiblle to display this in the userform?
For example: line 21
Userform location: London
Userform Name: Tom
 example.xls
Kiwi-123Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saurabh Singh TeotiaCommented:

Assuming you at that cell as in you have the cell selected when your launching the userform then this will do what you are looking for...

Saurabh...
example--1-.xls
Kiwi-123Author Commented:
HI saurabh726,

Thanks I'm half way there, but rather than select the next blank row. I'd like the userform to go from the cell/line which has been selected.

So if B24 were to be selected, the userform would open/input on line B24
Saurabh Singh TeotiaCommented:

Yeah thats what will happen..whatever value you have selected and when you hit show userform..its going to show that value.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Kiwi-123Author Commented:
So if I select B21

Amend the value, i.e change the name

What happens is a new line is added. I only want to amend the existing line.

I want to stop the code from intuitively selecting the next cell; I can choose whatever cell/line manually.
Saurabh Singh TeotiaCommented:

Yeah if you select the new line...and hit userform it will show that and if you ammend that value as well..it will show u the new one...
Kiwi-123Author Commented:
Yeah I don't ever want to create a new line, just amend an existing one. Or if no data is there add a brand new.
Saurabh Singh TeotiaCommented:

This is what the userform gonna do..pick up values from the line you are at...
Rory ArchibaldCommented:
Replace the userform code with this version:
Dim rngStart             As Excel.Range
Private Sub cmdCancel_Click()
   Unload Me
End Sub

Private Sub cmdPopulateRow_Click()

   With rngStart
      .Value = Combox1.Value
      .Offset(, 1).Value = Textbox1
      .Offset(, 2).Value = TextBox2
   End With
   Unload Me

End Sub

'Set up the data for the combo boxes.
Private Sub UserForm_Initialize()
   Set rngStart = Cells(ActiveCell.Row, "B")
   With rngStart
      Combox1.List = Sheets("DataSheet").Range("F2:F11").Value
      Combox1.Value = .Value
      Textbox1.Value = .Offset(0, 1).Value
      TextBox2.Value = .Offset(0, 2).Value
   End With
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.