Insert Name Alphabetically into Column with VBA

ciavala

Board Regular
Joined
Dec 7, 2003
Messages
223
Office Version
  1. 2010
Platform
  1. Windows
Hello Everyone,

Need some help with some VBA. I want to take the value of an input box, which is going to be a name of a new employee, and then look down the column of employee names alphabetically and insert new row with new name. Is this possible?


Thanks
ciavala
 
Add this
Code:
rEmpList(lPosition + 1).Interior.color=vbred

That worked great. Now, I realize that when I insert a new item, it does insert that name in the named range, as it is intended. However, it inserts a row only in that column. How do I make it so that it inserts a row across the entire worksheet?
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Change
Code:
rEmpList(lPosition + 1).Insert
to
Code:
rEmpList(lPosition + 1).EntireRow.Insert
 
Upvote 0
Glad to help & thanks for the feedback

Have a good weekend
 
Upvote 0
Wonderful bit of code. Thank you!

I noticed the Undo is not available after the code runs. In case one of my users adds a row in error, how do I programmatically 'turn on' the Undo option?

Thanks!
LBinGA
 
Upvote 0
Another question on this: How would I copy certain cells from above the newly added row if the name matches the cell above it.

For instance, if I add AXEL SMITH to A15, and that matches exactly the contents above it in A14, I would like to copy what is in cells M14-V14 to M15-V15.

Thanks again!
 
Last edited:
Upvote 0
Hi All,

Can somebody advise how can I make this brillant code work in all worksheets whitin workbook in the same time?

Thanks in advance!
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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