Insert Data Alphabetically Into Especific Range With Vba

Nikole28

New Member
Joined
Jun 15, 2015
Messages
1
Hello everybody, I am a beginner in vba (and this forum) and I found the Thread to create a row and input data alphabetically here:
I am using Excel 2013.
http://www.mrexcel.com/forum/excel-...ly-into-column-visual-basic-applications.html

:confused:
The problem is: I want the input to be started at the cell B6, B7, B8 and so on (until the end of the column, cell 65536 I believe).

I know that I should change my range input in the last row of this code, I managed to change the input to be in B but I can`t get it to work starting in the 6th row....

Can someone help me please?


Code:
Sub InsertName()
Dim sNewName As String
Dim lPosition As Long
Dim rEmpList As Range

Set rEmpList = Sheets("Sheet1").Range("B1:B65536")

sNewName = InputBox("Enter name of new employee")
On Error Resume Next 'if employee needs to go at start of list, Match will return #NA
lPosition = Application.WorksheetFunction.Match(sNewName, rEmpList, 1)
On Error GoTo 0 'revert to normal error handling (crashing)
Rows(lPosition + 1).Insert
[B]Range("B" & lPosition + 1).Value = sNewName
[/B]
End Sub


Thank you :D .
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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