Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Repeat Macro until Empty Cell Reached

How do I repeat the following macro until it reaches an empty cell?

ActiveCell.Offset(0, 0).Select
Application.SendKeys ("{F2}")
Application.SendKeys ("{Home}")
Application.SendKeys ("{Del 5}")
Application.SendKeys ("{ENTER}")



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Repeat Macro until Empty Cell Reached

option explicit
sub testme()
do
activecell.value = mid(activecell.value,6)
activecell.offset(1,0).select
if isempty(activecell) then
exit do
end if
loop
end sub




clpncsg wrote:

How do I repeat the following macro until it reaches an empty cell?

ActiveCell.Offset(0, 0).Select
Application.SendKeys ("{F2}")
Application.SendKeys ("{Home}")
Application.SendKeys ("{Del 5}")
Application.SendKeys ("{ENTER}")



--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Repeat Macro until Empty Cell Reached

Dave:

Thank you. This solution worked perfect.

Cindy

"Dave Peterson" wrote:

option explicit
sub testme()
do
activecell.value = mid(activecell.value,6)
activecell.offset(1,0).select
if isempty(activecell) then
exit do
end if
loop
end sub




clpncsg wrote:

How do I repeat the following macro until it reaches an empty cell?

ActiveCell.Offset(0, 0).Select
Application.SendKeys ("{F2}")
Application.SendKeys ("{Home}")
Application.SendKeys ("{Del 5}")
Application.SendKeys ("{ENTER}")



--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Repeat Macro until Empty Cell Reached

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Repeat Macro until Empty Cell Reached

here is a description of the original problem:

http://groups.google.ca/group/micros...2cb406126 0dd

the 3rd last post has a link to a photo ..

I cant figure out how to select the rows with the date directly. BUt
your macro that goes through the rows selects them ...

I found a function which will put the address of the first cell in A1
and the last cell in B1, so these cells would contain i.e. $B$34
and $B$412

The macro has to search 65000 lines unless I can select the end point
better ... I know how many data points I have so I could limit the
search to them. I just dont know how all that works in VBA ... also I
dont know how to address celles relatively,

for example I need cell Ax where x is the number in a cell ....

Matt

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Repeat Macro until Empty Cell Reached

Since you've separated your data into that area, it sure looks like you could
use:

range("somecellinthatarea").currentregion

And this is pretty much a plain text newsgroup. Many people will just skip by
your post if it contains attachments--pictures, too.

And if you add steps to click on links to download pictures, others will just
figure it's not worth their time.

I'd stick to plain text eplanations if I were posting.

Matt wrote:

here is a description of the original problem:

http://groups.google.ca/group/micros...2cb406126 0dd

the 3rd last post has a link to a photo ..

I cant figure out how to select the rows with the date directly. BUt
your macro that goes through the rows selects them ...

I found a function which will put the address of the first cell in A1
and the last cell in B1, so these cells would contain i.e. $B$34
and $B$412

The macro has to search 65000 lines unless I can select the end point
better ... I know how many data points I have so I could limit the
search to them. I just dont know how all that works in VBA ... also I
dont know how to address celles relatively,

for example I need cell Ax where x is the number in a cell ....

Matt


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Repeat Macro until Empty Cell Reached

I dont need them trimmed but I have not much clue about VBA so i just
took your code and added some more code.. I dont know what the
functions do and whats their syntax .. the excel help hasnt been much
help so far

I think I dont need that line: mycell.value = mid(mycell.value,6)

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Repeat Macro until Empty Cell Reached

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

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
macro - how to move to a specific cell and repeat andrea Excel Worksheet Functions 7 August 19th 08 12:39 AM
repeat macro until empty space in next column Sabba Efie Excel Worksheet Functions 1 August 15th 06 09:08 PM
How do I run a macro when a pre-determined time has been reached . NAMATA Excel Discussion (Misc queries) 1 April 19th 06 08:12 PM
Excel VBA - macro to recalculate random numbers until target reached gregaw Excel Programming 2 May 2nd 04 04:58 PM
HOW ? Running a different Macro if value reached bertieBassett Excel Programming 3 November 3rd 03 11:23 AM


All times are GMT +1. The time now is 07:55 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"