Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / December 2007

Tip: Looking for answers? Try searching our database.

IF  AND ELSE NOT WORKING

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thomsonpa - 10 Dec 2007 05:45 GMT
Can anybody help explain why the following code does not work?

The value in range D2 is =TEXT($C$2,"DDDDDD"), c2 is todays date

   Dim rng As Range

   Set rng = ActiveSheet.Range("D2")

   With rng
       If .Value = "MONDAY" Then
           'Do something,
           '
   Sheets("MON").Select
   ActiveSheet.Rows("7:126").Select
   Selection.Copy
   Sheets("24HR").Select
   ActiveSheet.Rows("7:126").Select
   ActiveSheet.Paste
       Else
          If .Value = "TUESDAY" Then
           'Do something,
           '
   Sheets("TUE").Select
   ActiveSheet.Rows("7:126").Select
   Selection.Copy
   Sheets("24HR").Select
   ActiveSheet.Rows("7:126").Select
   ActiveSheet.Paste
       Else
                  If .Value = "WEDNESDAY" Then
           'Do something,
           '
   Sheets("WED").Select
   ActiveSheet.Rows("7:126").Select
   Selection.Copy
   Sheets("24HR").Select
   ActiveSheet.Rows("7:126").Select
   ActiveSheet.Paste
       Else
       
   End If
   End If
   End If
   
   End With
Bob Phillips - 10 Dec 2007 09:11 GMT
Dim rng As Range

   Set rng = ActiveSheet.Range("D2")

   With rng
       Select Case UCase(.Value)

           Case "MONDAY"
               'Do something,
               '
               Sheets("24HR").Rows("7:126").Copy Sheets("MON").Range("A7")
           Case "TUESDAY"
               'Do something,
               '
               Sheets("24HR").Rows("7:126").Copy Sheets("TUE").Range("A7")
           Case "WEDNESDAY"
                   'Do something,
                   '
               Sheets("24HR").Rows("7:126").Copy Sheets("WED").Range("A7")
       End Select
   End With

or even

  Dim rng As Range

   Set rng = ActiveSheet.Range("D2")

   With rng
       'Do something,
       '
       Sheets("24HR").Rows("7:126").Copy Sheets(UCase(.Value)).Range("A7")
   End With

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

> Can anybody help explain why the following code does not work?
>
[quoted text clipped - 41 lines]
>
>    End With
thomsonpa - 10 Dec 2007 11:21 GMT
Great, many thanks works perfectly..

>    Dim rng As Range
>
[quoted text clipped - 75 lines]
> >
> >    End With
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.