ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping (https://www.excelbanter.com/excel-programming/364246-looping.html)

anderssweden

Looping
 
I am making a program that finds a cell and then checks the cells belonging
to same column. I am having trouble with the loop. I want to check the cells
and see if they are empty. If they are the loop is to be terminated and the
number of rows "belonging" to the loop shall be saved so that I know the
length of the list. However I do not know how to write the loop properly. I
am very thankful for any fast assistance. My code so far is:

Private Sub findValue2()
Dim rng As Range
Dim findVal As String
Dim i As Integer
Dim list As Integer
Set rng = Worksheets("Dimension").Cells.Find("qc", LookIn:=xlValues)
Worksheets("Indata").Range("K1") = rng.Address
rad = rng.Row
kolumn = rng.Column
i = 0
Do Until rng.Value < ""
Cells(rng.Row + i, rng.Column) = i
i = i + 1
list = list + 1




davegb

Looping
 
Sub rows()
Dim lRows As Long
lRows = ActiveCell.End(xlDown).Row - ActiveCell.Row + 1
MsgBox (lRows)
End Sub

anderssweden wrote:
I am making a program that finds a cell and then checks the cells belonging
to same column. I am having trouble with the loop. I want to check the cells
and see if they are empty. If they are the loop is to be terminated and the
number of rows "belonging" to the loop shall be saved so that I know the
length of the list. However I do not know how to write the loop properly. I
am very thankful for any fast assistance. My code so far is:

Private Sub findValue2()
Dim rng As Range
Dim findVal As String
Dim i As Integer
Dim list As Integer
Set rng = Worksheets("Dimension").Cells.Find("qc", LookIn:=xlValues)
Worksheets("Indata").Range("K1") = rng.Address
rad = rng.Row
kolumn = rng.Column
i = 0
Do Until rng.Value < ""
Cells(rng.Row + i, rng.Column) = i
i = i + 1
list = list + 1




All times are GMT +1. The time now is 01:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com