Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 31
Default IF AND ELSE NOT WORKING

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
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 10,593
Default IF AND ELSE NOT WORKING

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


--
---
HTH

Bob


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



"thomsonpa" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 31
Default IF AND ELSE NOT WORKING

Great, many thanks works perfectly..



"Bob Phillips" wrote:

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


--
---
HTH

Bob


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



"thomsonpa" wrote in message
...
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




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
IF not working amandooshna Excel Worksheet Functions 9 March 28th 07 02:11 PM
Sum(if not working Beverly C Excel Discussion (Misc queries) 5 February 6th 07 02:10 PM
if not working Micayla Bergen Excel Discussion (Misc queries) 3 March 13th 06 11:03 PM
was working, now :( Mark B Excel Worksheet Functions 1 January 17th 06 02:40 AM
Working out UK tax hawkeye uk New Users to Excel 6 March 11th 05 04:23 PM


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