Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Selecting rows and columns up to a certain point

I have an excel worksheet that contains various information. It mainly has 3
columns. The first Column is the Title, the second is the Year, and the third
is the Total (which comes from a different sheet).

After I have my infromation in the sheet, I sort it by the total column.
Some of the values are #N/A. I would like to selct the rows and columns up to
the #N/A.

For example:

The Worksheet:

A B C
1 Title1 2007 $58.95
2 Title2 2007 $75.25
3 Title3 2007 $38.66
4 Title4 2007 #N/A
5 Title5 2007 #N/A
6 Title6 2007 #N/A

In this example I would like to select A:1 thru C:3
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Selecting rows and columns up to a certain point

How do you want to select them? Click a button on the worksheet and
have it select the cells, or by using a hotkey?

Either way, this code will work on the sample data you gave:

Private Sub SelectNotNA()
Dim sStart As String, sEnd As String
Dim dX As Double

sStart = Range("A1").Address

For dX = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(dX, 3).Text = "#N/A" Then
sEnd = Cells(dX - 1, 3).Address
Exit For
End If
Next

Range(sStart, sEnd).Select
End Sub

Hope that helps!
Cory

On Oct 31, 2:16 pm, BZeyger wrote:
I have an excel worksheet that contains various information. It mainly has 3
columns. The first Column is the Title, the second is the Year, and the third
is the Total (which comes from a different sheet).

After I have my infromation in the sheet, I sort it by the total column.
Some of the values are #N/A. I would like to selct the rows and columns up to
the #N/A.

For example:

The Worksheet:

A B C
1 Title1 2007 $58.95
2 Title2 2007 $75.25
3 Title3 2007 $38.66
4 Title4 2007 #N/A
5 Title5 2007 #N/A
6 Title6 2007 #N/A

In this example I would like to select A:1 thru C:3



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Selecting rows and columns up to a certain point

You could select manually if as your example.

If #N/A would be random try DataFilterAutofilterCustomNot equal to......#N/A

The do what you want with visible cells.

I would suggest your trap for the #N/A errors and eliminate them at source by
leaving them look blank

Example only...........

=IF(ISNA(VLOOKUP(G7,$D$7:$F$23,2,FALSE)),"",VLOOKU P(G7,$D$7:$F$23,2,FALSE))

The when you sort they will fall to bottom.


Gord Dibben MS Excel MVP

On Wed, 31 Oct 2007 12:16:04 -0700, BZeyger
wrote:

I have an excel worksheet that contains various information. It mainly has 3
columns. The first Column is the Title, the second is the Year, and the third
is the Total (which comes from a different sheet).

After I have my infromation in the sheet, I sort it by the total column.
Some of the values are #N/A. I would like to selct the rows and columns up to
the #N/A.

For example:

The Worksheet:

A B C
1 Title1 2007 $58.95
2 Title2 2007 $75.25
3 Title3 2007 $38.66
4 Title4 2007 #N/A
5 Title5 2007 #N/A
6 Title6 2007 #N/A

In this example I would like to select A:1 thru C:3


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
Selecting data from columns and displaying them as rows chrisvail Excel Discussion (Misc queries) 2 October 7th 09 06:28 PM
selecting data from a combination of columns & rows. Browny Excel Discussion (Misc queries) 5 July 30th 09 09:47 AM
selecting non consectutive cells/rows/columns in excel 2007 PammyBB Excel Discussion (Misc queries) 3 March 26th 09 04:34 PM
selecting all blanks in multiple columns, then deleting those rows DSSdiva Excel Programming 6 May 12th 05 02:38 PM
Macro selecting blank rows/columns floss Excel Programming 1 April 27th 04 10:25 PM


All times are GMT +1. The time now is 12:28 AM.

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

About Us

"It's about Microsoft Excel"