Thanks.very useful for beginners like me.... On Mon, Jul 25, 2011 at 11:35 PM, XLS S <xlst...@gmail.com> wrote:
> please find the attachment for basic loop concept > > On Mon, Jul 25, 2011 at 5:50 PM, vijayajith VA <vijayajith...@gmail.com>wrote: > >> Hi rajan >> >> Can you explain >> below code >> st = st & vbTab & Arr(Rw, Cl) >> Next >> st = st & vbCrLf >> Next >> >> St means ? >> >> >> >> >> On Sun, Jul 24, 2011 at 1:08 PM, Rajan_Verma <rajanverma1...@gmail.com>wrote: >> >>> See if it Helps >>> >>> Option Base 1 >>> Sub StoreInArrya() >>> Dim Arr() As Variant >>> Dim rng As Range >>> Dim Rw As Integer >>> Dim Cl As Integer >>> >>> Set rng = Range("A1:C5") >>> ReDim Arr(rng.Cells.Rows.Count, rng.Cells.Columns.Count) >>> >>> For Rw = 1 To rng.Rows.Count >>> For Cl = 1 To rng.Columns.Count >>> Arr(Rw, Cl) = rng.Cells(Rw, Cl).Value >>> Next >>> Next >>> >>> For Rw = 1 To rng.Rows.Count >>> For Cl = 1 To rng.Columns.Count >>> st = st & vbTab & Arr(Rw, Cl) >>> Next >>> st = st & vbCrLf >>> Next >>> MsgBox st >>> End Sub >>> >>> -----Original Message----- >>> From: excel-macros@googlegroups.com [mailto: >>> excel-macros@googlegroups.com] >>> On Behalf Of netuser501 >>> Sent: Sunday, July 24, 2011 6:42 AM >>> To: MS EXCEL AND VBA MACROS >>> Subject: $$Excel-Macros$$ vba for loops -beginner >>> >>> Hi >>> >>> The question worksheets is filled with data on 5 rows and 3 columns. >>> I'd like to have this data stored in an Array. For testing purpose, I >>> want to test if the loop is "reading" the data with an integer "tmp" >>> that should return the number of cells filled in with data. >>> >>> Set wkb = ThisWorkbook >>> Set wks = wkb.Worksheets("questions") >>> >>> >>> For i = 0 To wks.Cells(i + 1, 1 = "" >>> For j = 0 To wks.Cells(i + 1, j + 1) = "" >>> tmp = tmp + 1 >>> Next j >>> Next i >>> >>> Why aren't Loop j and i looping? >>> >>> >>> >>> Another question : >>> >>> Is this possible to redim an array in a 2d for loop : >>> >>> dim SomeArray() as variant >>> redim SomeArray(0,0) 'A >>> >>> for i = 0 to MAXL >>> for j = 0 to MAXC >>> SomeArray(i,j) = cells(i+1,j+1) >>> redim preserve SomeArray(i,j+1) >>> next j >>> redim preserve SomeArray(i+1,j) 'j has still MAXC as value >>> next i >>> >>> I understand it's not making sense since MAXL and MAXC could be >>> declared in A. >>> >>> Back to the previous question it would make sense to redim a 2d array >>> in a for loop until a cell is empty in the column and a cell is empty >>> in the lines. >>> >>> Thanks for your precious help, >>> >>> -- >>> >>> ---------------------------------------------------------------------------- >>> ------ >>> 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 >> > > -- > > ---------------------------------------------------------------------------------- > 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