Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

how to ingreement the loop value automaticaly still last regards

  Asked By: Ernesta    Date: Dec 12    Category: MS Office    Views: 848
  

Can any one help me in vba code?

I need to increase the loop value automatically till lost regards in
the work sheet, but I don't how to write the code for that

Example , now I am manually increasing the loop value whenever loop
reaches the records

A= "prakash"

For I = 1 to 300
If Sheet2.cells(I,1)= A then
Sheet3.cells(I,3)= sheet2.cells(I,2)
End if
Next I

See the above example if the sheet2. Column1 less then 300 records
then, there is no problem in loop execution, but if the sheet2.
Column1 exceed more than 300 records, then, I cant get my datas, I
should manually increase I (loop) value 500, again the sheet2.
column1 exceed more then 500, I should increase I(loop) value
again, instead of this, is there any code for automatically increase
or execute till the last records, whenever regards increase, loop
also execute till the last record,

I hope you all understand my request, If any one help me it will be
very useful for me

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Brendan Smith     Answered On: Dec 12

It sounds like you are trying to determine the number of
records in a worksheet and that a record are defined as a row
in the sheet. You may find the CurrentRegion property useful.
I chose to use Cells(1,1) because your code  indicated it was
a valid field in a valid record.


Dim iRecordCount As Integer



iRecordCount = Sheet2.Cells(1, 1).CurrentRegion.Rows.Count

For I = 1 To iRecordCount

 




Tagged: