excel - Extract 1st letter from cell concatenate with another cell paste in third cell, then next row -
i need extract 1st letter cell b2
concatenate cell c2
paste in cell a2
, move next row , repeat till last data row.
i have following, partially works, works first row a2 fills down 1 string through rows till last data row.
sub username() dim rng range dim lastrow long sheets("sheet1") lastrow = .range("e" & .rows.count).end(xlup).row end each rng in sheets("sheet1").range("a2:a" & lastrow) rng.value = fusername(rng.value) next end sub
the function
function fusername(byval strusername string) string dim r string r = range("b2").select strusername = left(trim(r), 1) & " " & range("c2") fusername = strusername end function
try below code. have combined both procedure. no need of using function , no need of each loop
sub username() dim lastrow long sheets("sheet1") lastrow = .range("c" & .rows.count).end(xlup).row end range("a1:a" & lastrow).formular1c1 = "= left(rc[1],1) & rc[2]" end sub
Comments
Post a Comment