Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Mario
 
Posts: n/a
Default macro ...if command, I suppose...

Hi everybody

I recorded a macro wich finds the word "new date" and then copies the
corresponding rows in another sheet... (no problem as far as here).

I would like if it found no occurrence it ended e gave a message as "no
occurrence found" instead of indicating a run time error.

I think it need an if command, I tried but without success...

I send the mail

Cells.Find(What:="new date", After:=ActiveCell,
LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate.

ActiveCell.Offset(0, -1).Range("A1").Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlDown)).Select

Selection.Copy
Sheets("ScadenzeClienti").Select
Application.Goto Reference:="R1C1"
Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
End Sub

Thanks Mario



  #2   Report Post  
 
Posts: n/a
Default

Thank you JE
I succeed with: on error goto mymsg etc. etc., but i saved your code
becouse I want to study it.
Escuse me but what exactely is a "ranfe object?
And what does it mean IMO?
Sorry I haven't many familiarity with VB...
Ciao
Mario

  #3   Report Post  
Dave Peterson
 
Posts: n/a
Default

A range object is a group of one or more cells in a worksheet. He was saying
that instead of including a bunch of .selects in your code:

range("a1").select
selection.value = "hi there"

You could just work on the range itself:
range("a1").value = "hi there"

IMO = In My Opinion.

You can find the definition of more acronyms at:
http://www.hiddenlab.com/acronym

Take a look at JE's code. You'll see he tries to find it and then checks to see
if he found it or not.

I've found that when I use "on error resume next", I can hide an error that
shouldn't be hidden (that should be corrected).



wrote:

Thank you JE
I succeed with: on error goto mymsg etc. etc., but i saved your code
becouse I want to study it.
Escuse me but what exactely is a "ranfe object?
And what does it mean IMO?
Sorry I haven't many familiarity with VB...
Ciao
Mario


--

Dave Peterson
  #4   Report Post  
 
Posts: n/a
Default

Ok Dave I understand, I already use it. In italian it has another name.
In this case I am inside of a range.
When I register a macro with "relatives reference" (I hope it's the
right traslation from italian) and I go for example on the left or down
the code is like this: ActiveCell.Offset(1, 0).Range("A1").Select.
I don't know what does it mean Range("A1") becouse I don't select any
"absolute reference". May be I can delete it from code...
Thank you
Ciao
Mario

  #5   Report Post  
Dave Peterson
 
Posts: n/a
Default

Activecell.offset(1,0)
comes down one cell.
activecell.offset(1,0).range("a1")
is the first cell in the range described by activecell.offset(1,0)

These two are equivalent.

Activecell.range("a2")
would also be equivalent.

Imagine if you overlaid all the cells A1:IV655536 over a difference refence cell
(say C9).

So Range("C9").range("a1") is the same as range("c9")

Range("c9").range("B3")
means go over 1 column and down two more (1 is the row you're on).

Alan Beban has some notes at Chip Pearson's site that you may want to
read/print that have some more variations for using ranges.
http://www.cpearson.com/excel/cells.htm

wrote:

Ok Dave I understand, I already use it. In italian it has another name.
In this case I am inside of a range.
When I register a macro with "relatives reference" (I hope it's the
right traslation from italian) and I go for example on the left or down
the code is like this: ActiveCell.Offset(1, 0).Range("A1").Select.
I don't know what does it mean Range("A1") becouse I don't select any
"absolute reference". May be I can delete it from code...
Thank you
Ciao
Mario


--

Dave Peterson
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
excel macro inconsistency JM Excel Discussion (Misc queries) 2 December 9th 04 01:13 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
assign a macro to a control button ewan72 Excel Discussion (Misc queries) 1 December 3rd 04 02:04 PM
Macro help Jeff Garrett Excel Discussion (Misc queries) 11 December 1st 04 08:47 PM
macro interruption: help!!! mario milani Excel Discussion (Misc queries) 1 November 30th 04 06:02 PM


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