Dear sandeep/Mr. excel, Please find attached Sheet with Example.
-- Thanks & regards, Noorain Ansari *http://excelmacroworld.blogspot.com/*<http://excelmacroworld.blogspot.com/> *http://noorain-ansari.blogspot.com/* <http://noorain-ansari.blogspot.com/> On Fri, Oct 21, 2011 at 11:13 AM, <chhajersand...@gmail.com> wrote: > Dear Dilip, > > It wud have been gr8 if u also explain the codes in brief..when to use > which type code. > > Thanks and regards > CA Sandeep Kr Chhajer. > > Sent on my BlackBerry® from Vodafone > > -----Original Message----- > From: Dilip Pandey <dilipan...@gmail.com> > Sender: excel-macros@googlegroups.com > Date: Fri, 21 Oct 2011 11:09:04 > To: <excel-macros@googlegroups.com> > Reply-To: excel-macros@googlegroups.com > Subject: Re: $$Excel-Macros$$ How to learn vba > > Hi, > > Below are the explanation of looping codes:- > > Looping codes > ============ > > Do While/ Until "conditon" > -------- > -------- > Exit Do > -------- > -------- > Loop > > ````````````````````````````````````` > > > Do > --------- > --------- > Exit Do > --------- > --------- > Loop While / Until "condition" > > '''''''''''''''''''''''''''''''''''''' > > > While "condition" > -------- > -------- > -------- > Wend > > ```````````````````````````````````````` > > If "condition" Then > -------- > -------- > -------- > Else > -------- > -------- > -------- > End if > > `````````````````````````````````````````` > > Case "condition" > -------- > -------- > -------- > End Case > > `````````````````````````````````````````` > > For "condition" > -------- > -------- > -------- > Next > > `````````````````````````````````````````` > > For Each "condition" > -------- > -------- > -------- > Next > > ````````````````````````````````````````````` > > With "selection" > -------- > -------- > -------- > End with > > ============================================================= > > > Using "FOR" loop for each sheet in workbook > ============================================== > For i = 1 To Sheets.Count > Sheets(i).Select > 'your code here > Next > > > Regards, > DILIPandey > > > On 10/20/11, Mr excel <excelkeec...@gmail.com> wrote: > > Thanks all,for the replies.i had been working with the VBA macro > > recorder.Its really very funny & intersting to learn like this.But there > are > > some situation where i need to learn the programming techniques like Do > > Loops,While Loops etc which cannot be learnt from macro recording.Please > > suggest me some ideas or techniques for learning...Thanks in advance to > all > > those who had helped me... > > > > -- > > > ---------------------------------------------------------------------------------- > > Some important links for excel users: > > 1. Follow us on TWITTER for tips tricks and links : > > http://twitter.com/exceldailytip > > 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 > > 3. Excel tutorials at http://www.excel-macros.blogspot.com > > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > > > To post to this group, send email to excel-macros@googlegroups.com > > > > <><><><><><><><><><><><><><><><><><><><><><> > > Like our page on facebook , Just follow below link > > http://www.facebook.com/discussexcel > > > > > -- > Thanks & Regards, > > DILIP KUMAR PANDEY, mvp > MBA,B.Com(Hons),BCA > Mobile: +91 9810929744 > dilipan...@gmail.com > dilipan...@yahoo.com > New Delhi - 62, India > > -- > > ---------------------------------------------------------------------------------- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links : > http://twitter.com/exceldailytip > 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials at http://www.excel-macros.blogspot.com > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > Like our page on facebook , Just follow below link > http://www.facebook.com/discussexcel > > -- > > ---------------------------------------------------------------------------------- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links : > http://twitter.com/exceldailytip > 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials at http://www.excel-macros.blogspot.com > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > Like our page on facebook , Just follow below link > http://www.facebook.com/discussexcel > -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel
* **** ****** ******** ********** Sub test() Dim i, k, j As Integer, str As String j = InputBox("Please enter the Number of Stars") str = "*" ActiveCell.Select For i = 0 To j For k = 0 To i ActiveCell.Offset(i, -k).Value = str ActiveCell.Offset(i, k).Value = str Next Next End Sub --------------------------------------------------------------- *********** ******** **** ** * Sub test() Dim i, k, j As Integer, str As String j = InputBox("Please enter the Number of Stars") str = "*" For i = 0 To j For k = 0 To j ActiveCell.Offset(i, -k).Value = str ActiveCell.Offset(i, k).Value = str Next j = j - 1 Next End Sub ----------------------------------------------------------------- * ** *** ***** ****** ******** Sub test() Dim i, k, j As Integer, str As String j = InputBox("Please enter the Number of Stars") str = "*" For i = 0 To j For k = 0 To i ActiveCell.Offset(i, k).Value = str Next Next End Sub ----------------------------------------------------------------- * ** *** **** ***** ****** Sub test() Dim i, k, j As Integer, str As String j = InputBox("Please enter the Number of Stars") str = "*" For i = 0 To j For k = 0 To i ActiveCell.Offset(i, -k).Value = str Next Next End Sub ------------------------------------------------------------------ ********* ******** ****** **** ** * Sub test() Dim i, k, j As Integer, str As String j = InputBox("Please enter the Number of Stars") str = "*" For i = 0 To j For k = 0 To j ActiveCell.Offset(i, k).Value = str Next j = j - 1 Next End Sub -------------------------------------------------------------------- ********* ******* ***** **** *** * Sub test() Dim i, k, j As Integer, str As String j = InputBox("Please enter the Number of Stars") str = "*" For i = 0 To j For k = 0 To j ActiveCell.Offset(i, -k).Value = str Next j = j - 1 Next End Sub