I'm trying to create a value in this loop based on counting only cells in column M that contain values (text/numeric). Basically all the used cells.
loop, %CountUsed
{
send, ^{PgUp}
sleep, 1000
}
So if 40 cells in column M have values/used cells, I want to PgUp 40 times.
Count cells in Excel column containing values
Re: Count cells in Excel column containing values
I tried this, but it just hangs up. No errors though
And this without input reference:
Code: Select all
CountUsed := FileFrom.Sheets(1).UsedRange.Range("M:M")
loop, % CountUsed
{
send, ^{PgUp}
sleep, 1000
}
Code: Select all
loop, % FileFrom.Sheets(1).UsedRange.Range("M:M")
{
send, ^{PgUp}
sleep, 1000
}
Re: Count cells in Excel column containing values
Tried this one too, but got skunked
CountUsed := FileFrom.WorksheetFunction.CountA(Sheets(1).Range("M:M"))
loop, % CountUsed
{
send, ^{PgUp}
sleep, 1000
}
CountUsed := FileFrom.WorksheetFunction.CountA(Sheets(1).Range("M:M"))
loop, % CountUsed
{
send, ^{PgUp}
sleep, 1000
}
Re: Count cells in Excel column containing values
This one also. Probably making this harder than it is
myRange = Range("M:M")
NumRows = FileFrom..Sheets(1).CountA(myRange)
loop, NumRows
{
send, ^{PgUp}
sleep, 1000
}
myRange = Range("M:M")
NumRows = FileFrom..Sheets(1).CountA(myRange)
loop, NumRows
{
send, ^{PgUp}
sleep, 1000
}
Re: Count cells in Excel column containing values
Hey, try thishidefguy wrote:Tried this one too, but got skunkedCode: Select all
CountUsed := FileFrom.WorksheetFunction.CountA(Sheets(1).Range("M:M"))
Code: Select all
xlApp := ComObjActive("Excel.Application")
MsgBox % xlApp.WorksheetFunction.CountA( xlApp.Worksheets(1).Range("M:M") )
xlApp := ""
Code: Select all
xlApp := ComObjActive("Excel.Application")
MsgBox % xlApp.Worksheets("Sheet1").Range("M:M").Cells.SpecialCells(2).Count ; xlCellTypeConstants = 2
xlApp := ""
Re: Count cells in Excel column containing values
The first one worked. TY very much awel20
Re: Count cells in Excel column containing values
No problem. The second one worked for me too, but you probably need to change "Sheet1" to whatever your sheet is named, or just use 1 like in the other one.
Re: Count cells in Excel column containing values
Second one is good, but it hung up due to protected workbook.
Would you happen to know how to reference a variable or input within a Range("A1:A100")?
Example:
Gui, Add, Edit, x112 y70 w80 h20 vStartRow,
Range("A%StartRow%:A100")
Not sure how bad I botched that up
Would you happen to know how to reference a variable or input within a Range("A1:A100")?
Example:
Gui, Add, Edit, x112 y70 w80 h20 vStartRow,
Range("A%StartRow%:A100")
Not sure how bad I botched that up
Re: Count cells in Excel column containing values
Here's two ways to do it:
Code: Select all
startRow := 3
xlApp := ComObjActive("Excel.Application")
myRange := xlApp.Range("A" startRow ":A100")
Code: Select all
startRow := 3
xlApp := ComObjActive("Excel.Application")
topCell := xlApp.Cells(startRow, 1) ; Cell A3
botCell := xlApp.Cells(100, 1) ; Cell A100
myRange := xlApp.Range(topCell, botCell)
Re: Count cells in Excel column containing values
First one worked, first try. Thanks again friend
Who is online
Users browsing this forum: anonymous_user and 191 guests