View Full Version : [SOLVED:] Getting The Cells to focus!!! Using FOR LOOP to find and select only the last row)
Ladyj205
06-13-2018, 07:10 AM
I'm using MS Office 2010. win7
Somehow I've gotten the selected new rows to focus rather than the most recent one.
I need to use FOR Loop to find and select only the last row.
this what i have so far:
Option Explicit
Private Sub CommandButton1_Click()
Dim pass As String
pass = "abc1234"
ActiveSheet.Protect Password:=pass, UserInterFaceOnly:=True
With Range("A17:A42").SpecialCells(xlVisible).Areas(1)
.Offset(.Count).Resize(1).EntireRow.Hidden = False
ActiveSheet.Range("b19:d42").Select
End With
End Sub
Thankful for any and all help!!! Thanks a Million
Ladyj205
06-13-2018, 11:03 AM
Do i use something like:
FOR counter = start TO end [Step increment]
{...statements...}
NEXT [counter];
Bob Phillips
06-13-2018, 11:23 AM
Use
Cells(Rows.count, "A").End(xlUp).EntireRow.Select
Ladyj205
06-13-2018, 12:42 PM
Use
Cells(Rows.count, "A").End(xlUp).EntireRow.Select
i got an error when i added to what i got
Private Sub CommandButton1_Click()
Dim pass As String
pass = "nh1234"
ActiveSheet.Protect Password:=pass, UserInterFaceOnly:=True
With Range("A17:A42").SpecialCells(xlVisible).Areas(1)
.Offset(.Count).Resize(1).EntireRow.Hidden = False
Cells(Rows.Count, "A17:A42").End(xlUp).EntireRow.Select
ActiveSheet.Range("b19:d42").Select
End With
End Sub
Bob Phillips
06-13-2018, 01:32 PM
Not sure what the specialcells is all about, but maybe it should be
Private Sub CommandButton1_Click()
Dim pass As String
pass = "nh1234"
ActiveSheet.Protect Password:=pass, UserInterFaceOnly:=True
With Range("A17:A42").SpecialCells(xlVisible).Areas(1)
.Offset(.Count).Resize(1).EntireRow.Hidden = False
End With
Cells(Rows.Count, "A").End(xlUp).EntireRow.Select
End Sub
Ladyj205
06-13-2018, 02:23 PM
i have some hidden rows and the focus is not focusing on the the last row in the rows. it focus on the bottom of the sheet.
Bob Phillips
06-13-2018, 03:13 PM
Maybe post your workbook, I am working in the dark.
Ladyj205
06-14-2018, 06:58 AM
Maybe post your workbook, I am working in the dark.
sorry for the late and long reply. i had to get some sleep lol. i attached the workbook.
Bob Phillips
06-15-2018, 03:11 PM
I am not totally sure what should happen. Should a new line be inserted at row 42, but formatted as per row 41, and wit the next id? Should it be hidden or not? Will all rows other than id 1 always be hidden?
Ladyj205
06-17-2018, 07:32 PM
I am not totally sure what should happen. Should a new line be inserted at row 42, but formatted as per row 41, and wit the next id? Should it be hidden or not? Will all rows other than id 1 always be hidden?
I need to use FOR Loop to find and select only the last row. I just have my original vba code in. Sorry:( it should be hidden. When the user click on the new row button it shows one row at a time.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.