Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default VBA Programming.

It's been a while since I've done much VBA with Excel, so I'm a little rusty...

I'm working on a macro to do some formatting for me. I'm pulling in a file
from another program, into Excel. I want to Search all of Column B for a
string of all *'s. I've run a few tests with pulling in the data. And there
will only ever be one cell in the column that is all *'s. The tricky part
though, is that the actual number of *'s may vary from instance to instance.

So I'm looking for a way to search the column for a cell with a variable
number of *'s, but only *'s (some cells may have *'s and text); so that I can
then remove all rows from that row up.

Anyone have any thoughts to help get me started on this...?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default VBA Programming.

Sub stary()
Dim r As Range
For Each r In Selection
If IsEmpty(r.Value) Then
Else
If WorksheetFunction.Substitute(r.Value, "*", "") = "" Then
MsgBox (r.Address & " has only stars")
End If
End If
Next
End Sub

Select some cells and the macro will tell you which have only stars in them.
--
Gary's Student


"RSteph" wrote:

It's been a while since I've done much VBA with Excel, so I'm a little rusty...

I'm working on a macro to do some formatting for me. I'm pulling in a file
from another program, into Excel. I want to Search all of Column B for a
string of all *'s. I've run a few tests with pulling in the data. And there
will only ever be one cell in the column that is all *'s. The tricky part
though, is that the actual number of *'s may vary from instance to instance.

So I'm looking for a way to search the column for a cell with a variable
number of *'s, but only *'s (some cells may have *'s and text); so that I can
then remove all rows from that row up.

Anyone have any thoughts to help get me started on this...?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default VBA Programming.

That worked perfectly to find the row. Thank you very much.

Now if I wanted to delete all the rows from 1 to that row, how would I go
about doing that?

I looked at a method for selecting them like:

Rows("1:r.address").Select

I've tried a few ways to play with the 'r' variable, but I can't seem to
pull just the row from it. So that I can select all those rows, and delete
them.


"Gary''s Student" wrote:

Sub stary()
Dim r As Range
For Each r In Selection
If IsEmpty(r.Value) Then
Else
If WorksheetFunction.Substitute(r.Value, "*", "") = "" Then
MsgBox (r.Address & " has only stars")
End If
End If
Next
End Sub

Select some cells and the macro will tell you which have only stars in them.
--
Gary's Student


"RSteph" wrote:

It's been a while since I've done much VBA with Excel, so I'm a little rusty...

I'm working on a macro to do some formatting for me. I'm pulling in a file
from another program, into Excel. I want to Search all of Column B for a
string of all *'s. I've run a few tests with pulling in the data. And there
will only ever be one cell in the column that is all *'s. The tricky part
though, is that the actual number of *'s may vary from instance to instance.

So I'm looking for a way to search the column for a cell with a variable
number of *'s, but only *'s (some cells may have *'s and text); so that I can
then remove all rows from that row up.

Anyone have any thoughts to help get me started on this...?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default VBA Programming.

Actually I got it worked out now. I dropped the selection part and just used
the line:

Rows("1:" & r.Row).Delete

"RSteph" wrote:

That worked perfectly to find the row. Thank you very much.

Now if I wanted to delete all the rows from 1 to that row, how would I go
about doing that?

I looked at a method for selecting them like:

Rows("1:r.address").Select

I've tried a few ways to play with the 'r' variable, but I can't seem to
pull just the row from it. So that I can select all those rows, and delete
them.


"Gary''s Student" wrote:

Sub stary()
Dim r As Range
For Each r In Selection
If IsEmpty(r.Value) Then
Else
If WorksheetFunction.Substitute(r.Value, "*", "") = "" Then
MsgBox (r.Address & " has only stars")
End If
End If
Next
End Sub

Select some cells and the macro will tell you which have only stars in them.
--
Gary's Student


"RSteph" wrote:

It's been a while since I've done much VBA with Excel, so I'm a little rusty...

I'm working on a macro to do some formatting for me. I'm pulling in a file
from another program, into Excel. I want to Search all of Column B for a
string of all *'s. I've run a few tests with pulling in the data. And there
will only ever be one cell in the column that is all *'s. The tricky part
though, is that the actual number of *'s may vary from instance to instance.

So I'm looking for a way to search the column for a cell with a variable
number of *'s, but only *'s (some cells may have *'s and text); so that I can
then remove all rows from that row up.

Anyone have any thoughts to help get me started on this...?

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
VBA Programming [email protected] New Users to Excel 2 May 28th 08 08:38 PM
Programming Javad Excel Programming 1 January 29th 05 09:16 PM
programming VBA Mark Excel Programming 1 January 18th 05 09:11 AM
Help with programming soxn4n04 Excel Programming 0 November 18th 04 10:29 PM
vba programming sal Excel Programming 1 October 27th 03 07:44 PM


All times are GMT +1. The time now is 09:39 PM.

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"