View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Repeat Macro until Empty Cell Reached

I'm confused about what you want to do.

Usually I know the cell that I want to start with--I don't have to rely on
starting with the activecell. And going right and up and left until you find an
empty cell sounds like you could use a different approach.

And you're adjusting some cells (by trimming those 5 leading characters), but
not other cells. Is that really what you want?

For instance...

option explicit
sub Ed2()
dim myCell as range
dim myRng as range

set myrng = activecell.currentregion

for each mycell in myrng.cells
mycell.value = mid(mycell.value,6)
next mycell

'now you can use myRng as the basis for your chart, well, maybe...

end Sub

So you have a few questions to answer -- maybe just describe what you really
want.

And if you record a macro when you create the chart you like, you could post
that code and that code could be adjusted to use the range that meets your
description.



Matt wrote:

I modified it like this:

Sub ED()
Do
ActiveCell.Value = Mid(ActiveCell.Value, 6)
ActiveCell.Offset(1, 0).Select
If IsEmpty(ActiveCell) Then
Exit Do
End If
Loop

ActiveCell.Value = "END"
ActiveCell.Offset(0, 1).Select
Do
ActiveCell.Value = Mid(ActiveCell.Value, 6)
ActiveCell.Offset(-1, 0).Select
If IsEmpty(ActiveCell) Then
Exit Do
End If
Loop
ActiveCell.Offset(0, -1).Select
ActiveCell.Value = "START"

End Sub

Now what this does is it goes down until it finds an empty cell, then
goes right and then up until it finds an empty cell and left again.

Now this lets me find my range of used cells.

How can I now make a function which selects all cells between the cell
that say START and END and make a graph from that?

I really know nothing about VBA :( need help.

Matt


--

Dave Peterson