Thanks Praveen, I suggest you to take the code to a VB environment and test it. But the approach is good.
Dear Mike, the things which matters most is whether our problem is solved or not. If you need the answer in VBA, then you would have mentioned specifically a "VBA Solution Only". I generally avoid using VBA code for each and every thing, because commonly it is not appreciated by users / learners and moreove they find it difficult to understand and to further customize as per their changing needs. Best Regards, -- DILIP KUMAR PANDEY MBA-HR,B COM(Hons.),BCA Mobile: +91 9810929744 dilipan...@gmail.com dilipan...@yahoo.com New Delhi - 110062 On 12/24/09, kvc praveen kumar <pkkara...@gmail.com> wrote: > > Do You want to Use specific VBA coding or else You can use this formula > from Dilip directly like this in VBA: > Activecell.formula = "=IF(AND(A2="abcdCust",LEN(B2)= >> >> 6),0&B2,IF(AND(A2="xyzzCust",LEN(B2)=8),LEFT(B2,4)&"-"&RIGHT(B2,4),""))" > > > > On Thu, Dec 24, 2009 at 12:44 AM, mike <mwillia...@socal.rr.com> wrote: > >> Well that works if using a formula, how about implementing that using >> VBA? >> >> On Dec 6, 6:17 am, Dilip Pandey <dilipan...@gmail.com> wrote: >> > Dear Mike, >> > >> > Below is the formula for your requirement. >> > >> > >> =IF(AND(A2="abcdCust",LEN(B2)=6),0&B2,IF(AND(A2="xyzzCust",LEN(B2)=8),LEFT(B2,4)&"-"&RIGHT(B2,4),"")) >> > >> > Solved workbook is also attached. >> > >> > Best Regards, >> > -- >> > DILIP KUMAR PANDEY >> > MBA-HR,B COM(Hons.),BCA >> > Mobile: +91 9810929744 >> > dilipan...@gmail.com >> > dilipan...@yahoo.com >> > New Delhi - 110062 >> > >> > On 12/1/09, mike <mwillia...@socal.rr.com> wrote: >> > >> > >> > >> > >> > >> > > I have a set of data in Excel 2003 that is like this: >> > >> > > Customer OrderNum >> > > abcdCust 234567 >> > > xyzzCust 12345678 >> > > ...thousands of order entries, I'm just showing 2 taht are problems >> > > for me. >> > >> > > The first customer needs to have a padded 7 digit order number as >> > > "0234567" >> > > The second needs a dash placed between the first 4 and the last 4 like >> > > "1234-5678" >> > >> > > So, what I need is something like this: >> > >> > > if cell a1="abcdCust" AND len(b1)=6 then change (b1) to pad (b1) with >> > > zero >> > > if cell a1="xyzzCust" and len(b1) = 8 then change (b1) to add dash to >> > > (b1) after the first 4. >> > > next cell to evaluate a2...loop back until a(x) is blank. >> > >> > > Not all of my customers are these two(the only two with these issues), >> > > so if both if statements evaluate to false, then just move on. >> > >> > > I'm fairly up to speed with VBA, just not with excel and cell value >> > > evaluation. >> > > Any help will be appreciated. >> > >> > > -- >> > >> > > >> ---------------------------------------------------------------------------------- >> > > Some important links for excel users: >> > > 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at >> > >http://www.excelitems.com >> > > 2. Excel tutorials athttp://www.excel-macros.blogspot.com >> > > 3. Learn VBA Macros athttp://www.vbamacros.blogspot.com >> > > 4. Excel Tips and Tricks athttp://exceldailytip.blogspot.com >> > >> > > To post to this group, send email to excel-macros@googlegroups.com >> > > If you find any spam message in the group, please send an email to: >> > > Ayush Jain @ jainayus...@gmail.com or >> > > Ashish Jain @ 26may.1...@gmail.com >> > > <><><><><><><><><><><><><><><><><><><><><><> >> > > HELP US GROW !! >> > >> > > We reach over 6,500 subscribers worldwide and receive many nice notes >> about >> > > the learning and support from the group. Our goal is to have 10,000 >> > > subscribers by the end of 2009. Let friends and co-workers know they >> can >> > > subscribe to group at >> > >http://groups.google.com/group/excel-macros/subscribe >> > >> > >> > >> > IF Statement-by DILipandey.xls >> > 18KViewDownload- Hide quoted text - >> > >> > - Show quoted text - >> >> -- >> >> ---------------------------------------------------------------------------------- >> Some important links for excel users: >> 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at >> http://www.excelitems.com >> 2. Excel tutorials at http://www.excel-macros.blogspot.com >> 3. Learn VBA Macros at http://www.vbamacros.blogspot.com >> 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com >> >> >> To post to this group, send email to excel-macros@googlegroups.com >> If you find any spam message in the group, please send an email to: >> Ayush Jain @ jainayus...@gmail.com or >> Ashish Jain @ 26may.1...@gmail.com >> <><><><><><><><><><><><><><><><><><><><><><> >> HELP US GROW !! >> >> We reach over 6,500 subscribers worldwide and receive many nice notes >> about the learning and support from the group. Our goal is to have 10,000 >> subscribers by the end of 2009. Let friends and co-workers know they can >> subscribe to group at >> http://groups.google.com/group/excel-macros/subscribe > > > -- > > ---------------------------------------------------------------------------------- > Some important links for excel users: > 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at > http://www.excelitems.com > 2. Excel tutorials at http://www.excel-macros.blogspot.com > 3. Learn VBA Macros at http://www.vbamacros.blogspot.com > 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > > To post to this group, send email to excel-macros@googlegroups.com > If you find any spam message in the group, please send an email to: > Ayush Jain @ jainayus...@gmail.com or > Ashish Jain @ 26may.1...@gmail.com > <><><><><><><><><><><><><><><><><><><><><><> > HELP US GROW !! > > We reach over 6,500 subscribers worldwide and receive many nice notes about > the learning and support from the group. Our goal is to have 10,000 > subscribers by the end of 2009. Let friends and co-workers know they can > subscribe to group at > http://groups.google.com/group/excel-macros/subscribe > -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 6,500 subscribers worldwide and receive many nice notes about the learning and support from the group. Our goal is to have 10,000 subscribers by the end of 2009. Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe