ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro not consistant (https://www.excelbanter.com/excel-discussion-misc-queries/119675-re-macro-not-consistant.html)

Don Guillett

Macro not consistant
 
one liner
MsgBox Cells.Find("*", Range("A1"), xlFormulas, xlPart, xlByRows,
xlPrevious).Address

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message news:...
Maybe your last column is not the column with the last row?

--
Don Guillett
SalesAid Software

"grok" wrote in message
...
I'm using these statements in some macros:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, lc).End(xlUp).Row
Range(Cells(1, 1), Cells(lr, lc)).Select

Most of the time they work but some of the time they do not select all
the
rows leaving out one or two. Anyone know why?






PapaDos

Macro not consistant
 
Almost, but not quite right...
--
Regards,
Luc.

"Festina Lente"


"Don Guillett" wrote:

one liner
MsgBox Cells.Find("*", Range("A1"), xlFormulas, xlPart, xlByRows,
xlPrevious).Address

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message news:...
Maybe your last column is not the column with the last row?

--
Don Guillett
SalesAid Software

"grok" wrote in message
...
I'm using these statements in some macros:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, lc).End(xlUp).Row
Range(Cells(1, 1), Cells(lr, lc)).Select

Most of the time they work but some of the time they do not select all
the
rows leaving out one or two. Anyone know why?







Don Guillett

Macro not consistant
 
Just re-tested. Perhaps you have formatting or empty formulas

--
Don Guillett
SalesAid Software

"PapaDos" wrote in message
...
Almost, but not quite right...
--
Regards,
Luc.

"Festina Lente"


"Don Guillett" wrote:

one liner
MsgBox Cells.Find("*", Range("A1"), xlFormulas, xlPart, xlByRows,
xlPrevious).Address

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message news:...
Maybe your last column is not the column with the last row?

--
Don Guillett
SalesAid Software

"grok" wrote in message
...
I'm using these statements in some macros:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, lc).End(xlUp).Row
Range(Cells(1, 1), Cells(lr, lc)).Select

Most of the time they work but some of the time they do not select all
the
rows leaving out one or two. Anyone know why?








PapaDos

Macro not consistant
 
Let's say there is some data in A1, A2, A3, B1, B2.
Your formula will return A3, the original poster requirement is to return
B3...
--
Regards,
Luc.

"Festina Lente"


"Don Guillett" wrote:

Just re-tested. Perhaps you have formatting or empty formulas

--
Don Guillett
SalesAid Software

"PapaDos" wrote in message
...
Almost, but not quite right...
--
Regards,
Luc.

"Festina Lente"


"Don Guillett" wrote:

one liner
MsgBox Cells.Find("*", Range("A1"), xlFormulas, xlPart, xlByRows,
xlPrevious).Address

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message news:...
Maybe your last column is not the column with the last row?

--
Don Guillett
SalesAid Software

"grok" wrote in message
...
I'm using these statements in some macros:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, lc).End(xlUp).Row
Range(Cells(1, 1), Cells(lr, lc)).Select

Most of the time they work but some of the time they do not select all
the
rows leaving out one or two. Anyone know why?









Don Guillett

Macro not consistant
 

I thought the object was to find the last cell in the worksheet. This will
do the other.

Sub lastdata()
myLastCol = _
Cells.Find("*", After:=Cells(1), _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column
MsgBox myLastCol

mylastrow = _
Cells.Find("*", After:=Cells(1), _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
MsgBox mylastrow
MsgBox Cells(mylastrow, myLastCol).Address
End Sub

--
Don Guillett
SalesAid Software

"PapaDos" wrote in message
...
Let's say there is some data in A1, A2, A3, B1, B2.
Your formula will return A3, the original poster requirement is to return
B3...
--
Regards,
Luc.

"Festina Lente"


"Don Guillett" wrote:

Just re-tested. Perhaps you have formatting or empty formulas

--
Don Guillett
SalesAid Software

"PapaDos" wrote in message
...
Almost, but not quite right...
--
Regards,
Luc.

"Festina Lente"


"Don Guillett" wrote:

one liner
MsgBox Cells.Find("*", Range("A1"), xlFormulas, xlPart, xlByRows,
xlPrevious).Address

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message news:...
Maybe your last column is not the column with the last row?

--
Don Guillett
SalesAid Software

"grok" wrote in message
...
I'm using these statements in some macros:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, lc).End(xlUp).Row
Range(Cells(1, 1), Cells(lr, lc)).Select

Most of the time they work but some of the time they do not select
all
the
rows leaving out one or two. Anyone know why?












All times are GMT +1. The time now is 09:05 PM.

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