For...Next Statement vba

MissOctober

New Member
Joined
May 24, 2018
Messages
16
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.
so how would i put it in [h=1]For...Next Statement[/h]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
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Is this what you're after
Code:
Private Sub CommandButton1_Click()
   Dim pass As String
   pass = "nh1234"
   ActiveSheet.Protect Password:=pass, UserInterFaceOnly:=True

   With Range("A17:A42").SpecialCells(xlVisible).Areas(1)
      With .Offset(.Count).Resize(1)
         .EntireRow.Hidden = False
         .Offset(, 1).Select
      End With
   End With
End Sub
 
Upvote 0
Cross posted
https://www.ozgrid.com/forum/forum/...for-loop-to-find-and-select-only-the-last-row
http://www.vbaexpress.com/forum/sho...FOR-LOOP-to-find-and-select-only-the-last-row)

Cross-Posting
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
sorry about that. i couldnt get anyone to help me on here. i didnt know what else to do. i will keep that in mind next time. didnt mean to cross post. just looking for help
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top