Wednesday, 15 April 2015

excel - Find column starting with "Email" VBA -



excel - Find column starting with "Email" VBA -

i have limited knowledge of vba. however, help of google did script searches column called email. if finds it looks if in column commas. if yes, changes commas dots. however, solution case sensitive. if column name different, doesn't work. far know there 2 different options used in files script clean 1. email 2. email - personal email

i able create script work in email starting columns. tried specify "email*" didn't work. can help me?

sub mysample() sheets("data").activate dim cell excel.range dim ws excel.worksheet dim integer dim j integer each ws in excel.thisworkbook.sheets = ws.cells(1, excel.columns.count).end(excel.xltoleft).column j = 1 if ws.cells(1, j).value = "email" cells.replace what:=",", replacement:=".", lookat:=xlpart, _ searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _ replaceformat:=false end if next j next ws sheets("automation").activate msgbox "removing commas in emails - done!" end sub

i'd recommend utilize different approach: instead of looping trough cells of 1st column - utilize excel search identify e-mail column:

lookupstring = "email" set searchrange = activeworkbook.activesheet.range("1:1").find(lookupstring, lookin:=xlvalues, lookat:=xlpart, matchcase:=false)

with options given you'll find lookupstring value match, regardless of position , case in column name. replace activeworkbook.activesheet. part names of wb / sheet required.

further may utilize returned searchrange properties, such column, farther processing of info in column. luck!

excel vba excel-vba

No comments:

Post a Comment