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

Sorry, this is probably a daft question but its driving me nuts.

I want to write a routine where a picture becomes visible or no
depending on the magnitude of a number in a particular cell.

The following works ok on a single greater than condition
The image being contained in an image control obviously.

If Sheet5.Cells(6, 11) 40 Then
Sheet5.Image1.Visible = True
Else
Sheet5.Image1.Visible = False
End If

However i want to use the "OR" function to make the picture visible i
the magnitude of a number in a particular cell falls between
particular range so i think the code should be something like


If Sheet5.Cells(6, 11) 40 or < 300 Then
Sheet5.Image1.Visible = True
Else
Sheet5.Image1.Visible = False
End If


But the line 40 or < 300 does not work and i cant figure out why.

Any and all suggestions greatfully recieved !

regards
LaserFac

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Operator syntax - VBA problem

Hi Laserface,

Try:

If Sheet5.Cells(6, 11) 40 And _
Sheet5.Cells(6, 11) < 300 Then

---
Regards,
Norman



"laserface " wrote in message
...
Sorry, this is probably a daft question but its driving me nuts.

I want to write a routine where a picture becomes visible or not
depending on the magnitude of a number in a particular cell.

The following works ok on a single greater than condition
The image being contained in an image control obviously.

If Sheet5.Cells(6, 11) 40 Then
Sheet5.Image1.Visible = True
Else
Sheet5.Image1.Visible = False
End If

However i want to use the "OR" function to make the picture visible if
the magnitude of a number in a particular cell falls between a
particular range so i think the code should be something like


If Sheet5.Cells(6, 11) 40 or < 300 Then
Sheet5.Image1.Visible = True
Else
Sheet5.Image1.Visible = False
End If


But the line 40 or < 300 does not work and i cant figure out why.

Any and all suggestions greatfully recieved !

regards
LaserFace


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Operator syntax - VBA problem

An oft-overlooked language capability is how booleans work.

Sheet5.Image1.Visible = _
Sheet5.Cells(6, 11) 40 and Sheet5.Cells(6, 11) < 300
--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , laserface
says...
Sorry, this is probably a daft question but its driving me nuts.

I want to write a routine where a picture becomes visible or not
depending on the magnitude of a number in a particular cell.

The following works ok on a single greater than condition
The image being contained in an image control obviously.

If Sheet5.Cells(6, 11) 40 Then
Sheet5.Image1.Visible = True
Else
Sheet5.Image1.Visible = False
End If

However i want to use the "OR" function to make the picture visible if
the magnitude of a number in a particular cell falls between a
particular range so i think the code should be something like


If Sheet5.Cells(6, 11) 40 or < 300 Then
Sheet5.Image1.Visible = True
Else
Sheet5.Image1.Visible = False
End If


But the line 40 or < 300 does not work and i cant figure out why.

Any and all suggestions greatfully recieved !

regards
LaserFace


---
Message posted from http://www.ExcelForum.com/


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Operator syntax - VBA problem

Outstanding response on this forum.
I managed to resolve the problem after referrring to all your answer
using AND and OR operators.

Many thanks to you all for the excellent and rapid assistance.

regards,
Laserfac

--
Message posted from http://www.ExcelForum.com

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
Problem with Syntax? MurrayBarn Excel Worksheet Functions 8 June 12th 09 01:45 PM
SendKeys syntax problem VBAvirgin New Users to Excel 2 January 4th 06 04:42 PM
Syntax problem Alex H Excel Worksheet Functions 1 July 2nd 05 08:23 AM
Syntax error (missing operator) in query expression '6 Wescott Rd# shealy Excel Discussion (Misc queries) 0 June 9th 05 09:53 PM
Another Syntax Problem Sharlene England Excel Programming 2 December 2nd 03 10:04 PM


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