Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-27-2008, 05:10 PM
teepee
 
Posts: n/a
Trying to find the fourth blank cell in a column

Hello

I'm trying to find th fourth blank cell in a column and select a range based
on it. Should be simple but for some reason I can't makeit work. Anyone tell
me what I'm doing wrong? I'd be most grateful.

For background, I have some data followed by two blank cells, followed by
more data, folowed by a blank cell, followed by more data followed by
another blank cell, followed by more data followed by blank cells to the
end. It's the start of these final blanks I'm trying to find
programatically.

Problem is that after firstqun,the rest of the variables show as zero

Dim firstblank As String
Dim firstqun As String
Dim secondblank As Range
Dim secondqun As String
Dim thirdblank As Range
Dim thirdqun As String
Dim fourthblank As Range

firstblank = Columns("a:a").Find(What:="", LookAt:=xlWhole).Row
firstqun = firstblank + 2
Cells.FindNext(After:=ActiveCell).Activate


Set secondblank = Range("a" & firstqun & ":a1000").Find(What:="",
LookAt:=xlWhole)
secondqun = secondblank + 1
Cells.FindNext(After:=ActiveCell).Activate


Set thirdblank = Range("a" & secondqun & ":a1000").Find(What:="",
LookAt:=xlWhole)
thirdqun = thirdblank + 1
Cells.FindNext(After:=ActiveCell).Activate

Set fourthblank = Range("a" & thirdqun & ":a1000").Find(What:="",
LookAt:=xlWhole)
Range("A1:HH" & fourthblank).Select


Reply With Quote
  #2 (permalink)  
Old 04-27-2008, 05:25 PM
Jim Cone
 
Posts: n/a
Re: Trying to find the fourth blank cell in a column


Re: "It's the start of these final blanks I'm trying to find programmatically."
According to my count that would be the fifth blank cell?

'Working from the bottom up...
Dim FifthBlank as Range
Set FifthBlank = Cells(Rows.Count, "A").End (xlUp).Offset(1,0)
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"teepee"
wrote in message
Hello
I'm trying to find th fourth blank cell in a column and select a range based
on it. Should be simple but for some reason I can't makeit work. Anyone tell
me what I'm doing wrong? I'd be most grateful.

For background, I have some data followed by two blank cells, followed by
more data, folowed by a blank cell, followed by more data followed by
another blank cell, followed by more data followed by blank cells to the
end. It's the start of these final blanks I'm trying to find
programatically.

Problem is that after firstqun,the rest of the variables show as zero

Dim firstblank As String
Dim firstqun As String
Dim secondblank As Range
Dim secondqun As String
Dim thirdblank As Range
Dim thirdqun As String
Dim fourthblank As Range

firstblank = Columns("a:a").Find(What:="", LookAt:=xlWhole).Row
firstqun = firstblank + 2
Cells.FindNext(After:=ActiveCell).Activate


Set secondblank = Range("a" & firstqun & ":a1000").Find(What:="",
LookAt:=xlWhole)
secondqun = secondblank + 1
Cells.FindNext(After:=ActiveCell).Activate


Set thirdblank = Range("a" & secondqun & ":a1000").Find(What:="",
LookAt:=xlWhole)
thirdqun = thirdblank + 1
Cells.FindNext(After:=ActiveCell).Activate

Set fourthblank = Range("a" & thirdqun & ":a1000").Find(What:="",
LookAt:=xlWhole)
Range("A1:HH" & fourthblank).Select


Reply With Quote
  #3 (permalink)  
Old 04-27-2008, 05:25 PM
Bob Phillips
 
Posts: n/a
Re: Trying to find the fourth blank cell in a column

Dim firstblank As Range
Dim firstqun As Range
Dim secondblank As Range
Dim secondqun As Range
Dim thirdblank As Range
Dim thirdqun As Range
Dim fourthblank As Range

Set firstblank = Columns("a:a").Find(What:="", LookAt:=xlWhole)
Set firstqun = firstblank.Offset(2, 0)

Set secondblank = Columns("a:a").FindNext(after:=firstqun)
Set secondqun = secondblank.Offset(1, 0)


Set thirdblank = Columns("a:a").FindNext(after:=secondqun)
Set thirdqun = thirdblank.Offset(1, 0)

Set fourthblank = Columns("a:a").FindNext(after:=thirdqun)
Range("A1:HH" & fourthblank.Row).Select


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"teepee" <nomail@nomail.com> wrote in message
news:4814a593$1@newsgate.x-privat.org...
> Hello
>
> I'm trying to find th fourth blank cell in a column and select a range
> based on it. Should be simple but for some reason I can't makeit work.
> Anyone tell me what I'm doing wrong? I'd be most grateful.
>
> For background, I have some data followed by two blank cells, followed by
> more data, folowed by a blank cell, followed by more data followed by
> another blank cell, followed by more data followed by blank cells to the
> end. It's the start of these final blanks I'm trying to find
> programatically.
>
> Problem is that after firstqun,the rest of the variables show as zero
>
> Dim firstblank As String
> Dim firstqun As String
> Dim secondblank As Range
> Dim secondqun As String
> Dim thirdblank As Range
> Dim thirdqun As String
> Dim fourthblank As Range
>
> firstblank = Columns("a:a").Find(What:="", LookAt:=xlWhole).Row
> firstqun = firstblank + 2
> Cells.FindNext(After:=ActiveCell).Activate
>
>
> Set secondblank = Range("a" & firstqun & ":a1000").Find(What:="",
> LookAt:=xlWhole)
> secondqun = secondblank + 1
> Cells.FindNext(After:=ActiveCell).Activate
>
>
> Set thirdblank = Range("a" & secondqun & ":a1000").Find(What:="",
> LookAt:=xlWhole)
> thirdqun = thirdblank + 1
> Cells.FindNext(After:=ActiveCell).Activate
>
> Set fourthblank = Range("a" & thirdqun & ":a1000").Find(What:="",
> LookAt:=xlWhole)
> Range("A1:HH" & fourthblank).Select
>



Reply With Quote
  #4 (permalink)  
Old 04-27-2008, 06:09 PM
Ron Rosenfeld
 
Posts: n/a
Re: Trying to find the fourth blank cell in a column

On Sun, 27 Apr 2008 17:10:55 +0100, "teepee" <nomail@nomail.com> wrote:

>I'm trying to find th fourth blank cell in a column and select a range based
>on it. Should be simple but for some reason I can't makeit work. Anyone tell
>me what I'm doing wrong? I'd be most grateful.


I would approach it a bit differently, storing the blank cells in an array, and
then selecting the one you want:

======================
Option Explicit
Sub GetBlankCells()
Dim BlankCells(0 To 3) As Range
Dim rg As Range, c As Range
Dim i As Long
Set rg = Range("A:A")
Set rg = rg.SpecialCells(xlCellTypeBlanks)
i = 0
For Each c In rg
Set BlankCells(i) = c
i = i + 1
If i > 3 Then Exit For
Next c
For i = 0 To 3
Debug.Print BlankCells(i).Address
Next i
End Sub
==============================

So BlankCells(3) would be the fourth empty cell.



--ron
Reply With Quote
  #5 (permalink)  
Old 04-27-2008, 06:30 PM
Ron Rosenfeld
 
Posts: n/a
Re: Trying to find the fourth blank cell in a column

On Sun, 27 Apr 2008 17:10:55 +0100, "teepee" <nomail@nomail.com> wrote:

>Hello
>
>I'm trying to find th fourth blank cell in a column and select a range based
>on it. Should be simple but for some reason I can't makeit work. Anyone tell
>me what I'm doing wrong? I'd be most grateful.
>
>For background, I have some data followed by two blank cells, followed by
>more data, folowed by a blank cell, followed by more data followed by
>another blank cell, followed by more data followed by blank cells to the
>end. It's the start of these final blanks I'm trying to find
>programatically.
>


It occurs to me you might want to be searching for cells that display a blank,
and not cells that are actually empty. If so, something like:

========================
Sub GetNullStringCells()
Dim BlankCells(0 To 3) As Range
Dim rg As Range
Dim i As Long
Set rg = Range("A:A")
Set BlankCells(0) = rg.Find("", LookIn:=xlValues)
For i = 1 To 3
Set BlankCells(i) = rg.FindNext(BlankCells(i - 1))
Next i
For i = 0 To 3
Debug.Print BlankCells(i).Address
Next i
End Sub
============================
--ron
Reply With Quote
  #6 (permalink)  
Old 04-27-2008, 06:39 PM
Ron Rosenfeld
 
Posts: n/a
Re: Trying to find the fourth blank cell in a column

On Sun, 27 Apr 2008 13:09:24 -0400, Ron Rosenfeld <ronrosenfeld@nospam.org>
wrote:

>On Sun, 27 Apr 2008 17:10:55 +0100, "teepee" <nomail@nomail.com> wrote:
>
>>I'm trying to find th fourth blank cell in a column and select a range based
>>on it. Should be simple but for some reason I can't makeit work. Anyone tell
>>me what I'm doing wrong? I'd be most grateful.

>
>I would approach it a bit differently, storing the blank cells in an array, and
>then selecting the one you want:
>
>======================
>Option Explicit
>Sub GetBlankCells()
>Dim BlankCells(0 To 3) As Range
>Dim rg As Range, c As Range
>Dim i As Long
>Set rg = Range("A:A")
>Set rg = rg.SpecialCells(xlCellTypeBlanks)
> i = 0
>For Each c In rg
> Set BlankCells(i) = c
> i = i + 1
> If i > 3 Then Exit For
>Next c
>For i = 0 To 3
> Debug.Print BlankCells(i).Address
>Next i
>End Sub
>==============================
>
>So BlankCells(3) would be the fourth empty cell.
>
>
>
>--ron


Rereading your original post, I'm not sure how you want to set the range after
you've found each blank cell. I'm also not sure if you want to skip the second
blank cell.
--ron
Reply With Quote
  #7 (permalink)  
Old 04-27-2008, 06:39 PM
Ron Rosenfeld
 
Posts: n/a
Re: Trying to find the fourth blank cell in a column

On Sun, 27 Apr 2008 13:30:03 -0400, Ron Rosenfeld <ronrosenfeld@nospam.org>
wrote:

>On Sun, 27 Apr 2008 17:10:55 +0100, "teepee" <nomail@nomail.com> wrote:
>
>>Hello
>>
>>I'm trying to find th fourth blank cell in a column and select a range based
>>on it. Should be simple but for some reason I can't makeit work. Anyone tell
>>me what I'm doing wrong? I'd be most grateful.
>>
>>For background, I have some data followed by two blank cells, followed by
>>more data, folowed by a blank cell, followed by more data followed by
>>another blank cell, followed by more data followed by blank cells to the
>>end. It's the start of these final blanks I'm trying to find
>>programatically.
>>

>
>It occurs to me you might want to be searching for cells that display a blank,
>and not cells that are actually empty. If so, something like:
>
>========================
>Sub GetNullStringCells()
>Dim BlankCells(0 To 3) As Range
>Dim rg As Range
>Dim i As Long
>Set rg = Range("A:A")
> Set BlankCells(0) = rg.Find("", LookIn:=xlValues)
> For i = 1 To 3
> Set BlankCells(i) = rg.FindNext(BlankCells(i - 1))
> Next i
>For i = 0 To 3
> Debug.Print BlankCells(i).Address
>Next i
>End Sub
>============================
>--ron



Rereading your original post, I'm not sure how you want to set the range after
you've found each blank cell. I'm also not sure if you want to skip the second
blank cell.
--ron
Reply With Quote
  #8 (permalink)  
Old 04-28-2008, 12:09 AM
teepee
 
Posts: n/a
Re: Trying to find the fourth blank cell in a column

Many thanks Bob and Ron. I'm in your debt.


Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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



All times are GMT. The time now is 04:44 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Remortgages | Adverse Credit Remortgage | Loans | Free Advertising | Credit Cards



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114