PC Review


Reply
Thread Tools Rate Thread

code for selecting 2nd visible row

 
 
=?Utf-8?B?S25veA==?=
Guest
Posts: n/a
 
      6th Apr 2007
After an autofilter I want to select the 2nd visible row and column C and
paste something in there. What is the code for this?

Sheets("Sheet1").Select
Range("C????????").Select
ActiveSheet.Paste
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      6th Apr 2007
One way:

Option Explicit
Sub testme()
Dim myVisRow As Long
Dim myCell As Range
Dim vCtr As Long
Dim WhichVisRow As Long
Dim vRng As Range
Dim wks As Worksheet

Dim SomeRngToCopy as Range

Set wks = ActiveSheet

WhichVisRow = 2
With wks.AutoFilter.Range
'ignore the header and make sure there are
'enough visible rows
If (.Columns(1).Cells.SpecialCells(xlCellTypeVisible).Count - 1) _
< WhichVisRow Then
MsgBox "Not enough visible rows"
Exit Sub
End If

Set vRng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)

vCtr = 0
For Each myCell In vRng.Cells
vCtr = vCtr + 1
If vCtr = WhichVisRow Then
myVisRow = myCell.Row
Exit For
End If
Next myCell

'do your copy and paste
set somerngtocopy = worksheets("somesheetname").range("x99")
somerngtocopy.copy _
destination:=.cells(myvisrow,"C")

End With

End Sub

I assumed that you meant the 2nd visible row of the data--not including the
header.


Knox wrote:
>
> After an autofilter I want to select the 2nd visible row and column C and
> paste something in there. What is the code for this?
>
> Sheets("Sheet1").Select
> Range("C????????").Select
> ActiveSheet.Paste


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoFilter & Selecting First Visible Cell Simon Microsoft Excel Programming 2 1st Oct 2009 01:07 PM
Selecting an offset of a range of visible cells, but only those <>0? Keith Microsoft Excel Programming 2 4th Feb 2007 08:12 PM
Can selecting a combo box makes a text box visible again =?Utf-8?B?cGF0ZW50aW52?= Microsoft Access 7 1st Oct 2005 02:30 PM
Selecting Column of Visible AutoFiltered Cells. =?Utf-8?B?Um9iZXJ0IENocmlzdGll?= Microsoft Excel Programming 9 12th Jan 2005 11:15 PM
Selecting visible contents while skipping over hidden Jamie Martin Microsoft Excel Misc 3 19th Aug 2003 06:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:23 AM.