#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VB Code

I spent what seemed a lifetime learning excel macro language and now think
its about time I embraced this new fangled vb code. I cannot seem to grasp
how error checking works in vb, it was so simple in macro language. I'm sure
its as simple in vb, but I need some guidance.


Can somebody please help with the vb code for the following macro4 code.

A1=SELECT("Range_1")
A2=ERROR(FALSE)
A3=FORMULA.FIND("Something")
A4=IF(A3=TRUE,GOTO(A7))
A5=ALERT("Not found")
A6=HALT()
A7=ALERT("Found")
A8=HALT()



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VB Code

Dim c As Range

On Error Resume Next
Set c = Range("Range_1").Find("Something")
On Error Goto 0
If c Is Nothing Then
Msgbox "Not Found
Else
Msgbox "Found"
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Hal" wrote in message
...
I spent what seemed a lifetime learning excel macro language and now think
its about time I embraced this new fangled vb code. I cannot seem to grasp
how error checking works in vb, it was so simple in macro language. I'm

sure
its as simple in vb, but I need some guidance.


Can somebody please help with the vb code for the following macro4 code.

A1=SELECT("Range_1")
A2=ERROR(FALSE)
A3=FORMULA.FIND("Something")
A4=IF(A3=TRUE,GOTO(A7))
A5=ALERT("Not found")
A6=HALT()
A7=ALERT("Found")
A8=HALT()





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default VB Code

This code is a little more than you asked for but it serves to illustrate
what you want. It creates a worksheet object that is the same as the active
sheet. You could make it equal to any sheet in the book. It creates a range
object (rngToSearch) that is cells A1 to A100 on the worksheet. It then tries
to set the last range object (rngFound) equal to the a cell with the word
"Something" in it. It then determines if rngFound was successfully set (if it
wasn't then it will still be nothing). Finally it displays message boxes with
the results.

Sub Test()
Dim wksCurrent As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range

Set wksCurrent = ActiveSheet
Set rngToSearch = wksCurrent.Range("A1:A100")
Set rngFound = rngToSearch.Find("Something")

If rngFound Is Nothing Then
MsgBox "Not Found"
Else
MsgBox "Found Something at address" & rngFound.Address
End If
End Sub

HTH

"Hal" wrote:

I spent what seemed a lifetime learning excel macro language and now think
its about time I embraced this new fangled vb code. I cannot seem to grasp
how error checking works in vb, it was so simple in macro language. I'm sure
its as simple in vb, but I need some guidance.


Can somebody please help with the vb code for the following macro4 code.

A1=SELECT("Range_1")
A2=ERROR(FALSE)
A3=FORMULA.FIND("Something")
A4=IF(A3=TRUE,GOTO(A7))
A5=ALERT("Not found")
A6=HALT()
A7=ALERT("Found")
A8=HALT()




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default VB Code

You know how I love to bug you Bob. What is the point to your statement

on error resume next

If the range object can not be set then c remains as nothing and no error is
generated. I tried your code both ways and it works just fine without the
error statements.

"Bob Phillips" wrote:

Dim c As Range

On Error Resume Next
Set c = Range("Range_1").Find("Something")
On Error Goto 0
If c Is Nothing Then
Msgbox "Not Found
Else
Msgbox "Found"
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Hal" wrote in message
...
I spent what seemed a lifetime learning excel macro language and now think
its about time I embraced this new fangled vb code. I cannot seem to grasp
how error checking works in vb, it was so simple in macro language. I'm

sure
its as simple in vb, but I need some guidance.


Can somebody please help with the vb code for the following macro4 code.

A1=SELECT("Range_1")
A2=ERROR(FALSE)
A3=FORMULA.FIND("Something")
A4=IF(A3=TRUE,GOTO(A7))
A5=ALERT("Not found")
A6=HALT()
A7=ALERT("Found")
A8=HALT()






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default VB Code


"Bob Phillips" wrote in message
...
Dim c As Range

On Error Resume Next
Set c = Range("Range_1").Find("Something")
On Error Goto 0
If c Is Nothing Then
Msgbox "Not Found
Else
Msgbox "Found"
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Hal" wrote in message
...
I spent what seemed a lifetime learning excel macro language and now think
its about time I embraced this new fangled vb code.



Does someone know if VBA is also abandoned by Microsoft for a .NET version ??

Gys





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default VB Code

I'm guessing muscle memory <bg. Sometimes fingers just take over for the
brain.

(Well, that explains why I sometimes do this!)

Jim Thomlinson wrote:

You know how I love to bug you Bob. What is the point to your statement

on error resume next

If the range object can not be set then c remains as nothing and no error is
generated. I tried your code both ways and it works just fine without the
error statements.

"Bob Phillips" wrote:

Dim c As Range

On Error Resume Next
Set c = Range("Range_1").Find("Something")
On Error Goto 0
If c Is Nothing Then
Msgbox "Not Found
Else
Msgbox "Found"
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Hal" wrote in message
...
I spent what seemed a lifetime learning excel macro language and now think
its about time I embraced this new fangled vb code. I cannot seem to grasp
how error checking works in vb, it was so simple in macro language. I'm

sure
its as simple in vb, but I need some guidance.


Can somebody please help with the vb code for the following macro4 code.

A1=SELECT("Range_1")
A2=ERROR(FALSE)
A3=FORMULA.FIND("Something")
A4=IF(A3=TRUE,GOTO(A7))
A5=ALERT("Not found")
A6=HALT()
A7=ALERT("Found")
A8=HALT()







--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default VB Code

I am still waiting for the day that my brain takes over for my mouth. That
will keep me out of lots of trouble... :)

"Dave Peterson" wrote:

I'm guessing muscle memory <bg. Sometimes fingers just take over for the
brain.

(Well, that explains why I sometimes do this!)

Jim Thomlinson wrote:

You know how I love to bug you Bob. What is the point to your statement

on error resume next

If the range object can not be set then c remains as nothing and no error is
generated. I tried your code both ways and it works just fine without the
error statements.

"Bob Phillips" wrote:

Dim c As Range

On Error Resume Next
Set c = Range("Range_1").Find("Something")
On Error Goto 0
If c Is Nothing Then
Msgbox "Not Found
Else
Msgbox "Found"
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Hal" wrote in message
...
I spent what seemed a lifetime learning excel macro language and now think
its about time I embraced this new fangled vb code. I cannot seem to grasp
how error checking works in vb, it was so simple in macro language. I'm
sure
its as simple in vb, but I need some guidance.


Can somebody please help with the vb code for the following macro4 code.

A1=SELECT("Range_1")
A2=ERROR(FALSE)
A3=FORMULA.FIND("Something")
A4=IF(A3=TRUE,GOTO(A7))
A5=ALERT("Not found")
A6=HALT()
A7=ALERT("Found")
A8=HALT()







--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VB Code

Have a look at this discussion:

http://www.dicks-blog.com/archives/2...c-vb/#comments

Watch for wrap around dropping the final s

--

HTH

RP
(remove nothere from the email address if mailing direct)


"GysdeJongh" wrote in message
...

"Bob Phillips" wrote in message
...
Dim c As Range

On Error Resume Next
Set c = Range("Range_1").Find("Something")
On Error Goto 0
If c Is Nothing Then
Msgbox "Not Found
Else
Msgbox "Found"
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Hal" wrote in message
...
I spent what seemed a lifetime learning excel macro language and now

think
its about time I embraced this new fangled vb code.



Does someone know if VBA is also abandoned by Microsoft for a .NET version

??

Gys





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VB Code


"Jim Thomlinson" wrote in message
...
You know how I love to bug you Bob. What is the point to your statement


I wake up wondering what challenges Jim has set me for today <vbg

on error resume next

If the range object can not be set then c remains as nothing and no error

is
generated. I tried your code both ways and it works just fine without the
error statements.



Not for me it doesn't, it fails nastily with 'Method Range 'of Object'
_Global Failed'.

It is not the Set c that is failing, but the Find.



Bob


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VB Code

Many Thanks for all your replies, The trouble with being an old 1960's
supercomputer, I just can't keep up with all the new technology since
2001 :-)



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default VB Code

Thank you for this link ! . Peoples comments like : "For an VBA speaker,
learning VB.NET is like learning Klingon" make me worry as we also use a lot of
VBA just for simple tasks

Gys





"Bob Phillips" wrote in message
...
Have a look at this discussion:

http://www.dicks-blog.com/archives/2...c-vb/#comments

Watch for wrap around dropping the final s

--

HTH

RP
(remove nothere from the email address if mailing direct)


"GysdeJongh" wrote in message
...

"Bob Phillips" wrote in message
...
Dim c As Range

On Error Resume Next
Set c = Range("Range_1").Find("Something")
On Error Goto 0
If c Is Nothing Then
Msgbox "Not Found
Else
Msgbox "Found"
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Hal" wrote in message
...
I spent what seemed a lifetime learning excel macro language and now

think
its about time I embraced this new fangled vb code.



Does someone know if VBA is also abandoned by Microsoft for a .NET version

??

Gys






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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM
option buttons run Click code when value is changed via VBA code neonangel Excel Programming 5 July 27th 04 08:32 AM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM


All times are GMT +1. The time now is 01:46 AM.

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"