Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default code for selecting 2nd visible row

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default code for selecting 2nd visible row

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP: Selecting Non-Visible (Hidden) Cells with AutoFilter Applied west8100 Excel Discussion (Misc queries) 3 February 11th 09 11:26 PM
HELP: Selecting Non-Visible (Hidden) Cells with AutoFilter Applied west8100 Excel Discussion (Misc queries) 0 February 10th 09 09:28 PM
HELP: Selecting Non-Visible (Hidden) Cells with AutoFilter Applied west8100 Excel Discussion (Misc queries) 0 February 10th 09 09:28 PM
Selecting an offset of a range of visible cells, but only those <0? Keith Excel Programming 2 February 4th 07 08:12 PM
Selecting Column of Visible AutoFiltered Cells. Robert Christie[_3_] Excel Programming 9 January 12th 05 11:15 PM


All times are GMT +1. The time now is 03:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"