Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto insert cells in excel

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
If I have a spreadsheet with say 10 Columns 200 rows and I sort the data into "peoples names" alphabetical assending order (20 different names perhaps)
is it possible to do something that will automatically insert a blank row as soon as a new name is reached ?
 
Assuming that it's column A that contains the data fields of interest and also that the table has already been sorted by column A then:

Set stcell = Range("A2")
do until stcell.range("a2").value = ""
set nxtcell <> stcell.offset(1,0)
if stcell.value = stcell.offset(-1,0).value then
stcell.entirerow.insert
endif
set stcell = nxtcell
loop


should do the trick although it might fall over if you get balnk cells as a matter of course in column A. The other thing for you to bear in mind is a possible requirement for fuzzy matching which isn't catered for in the above.

Bryan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top