View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default If cell D2 begins with 00 then E2 =

the rest on column E was labeled "INT" including the E1 which was the
header.


Well, you said you wanted everything else in column E to be "INTL",
and you didn't mention that E1 was a header. Try the following.

Sub AAA()
Dim RR As Range
Select Case UCase(Left(Range("D2").Text, 2))
Case "00", "11", "CA"
Application.EnableEvents = False
With ActiveSheet
Set RR = .Cells(2, 5).Resize(.UsedRange.Rows.Count)
RR.Value = "INTL"
End With
Range("E2").Value = "DOM"
Application.EnableEvents = True
Case Else
End Select
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com




On Mon, 22 Feb 2010 11:48:26 -0800, "dizzl3e"
wrote:

Thanks, but that didn't work. It labeled E2 as "DOM" which is right, but
the rest on column E was labeled "INT" including the E1 which was the
header.

"Chip Pearson" wrote in message
.. .
The code would look like the following:

Sub AAA()
Select Case UCase(Left(Range("D2").Text, 2))
Case "00", "11", "CA"
Application.Intersect(ActiveSheet.UsedRange, _
Range("E2").EntireColumn).Value = "INTL"
Range("E2").Value = "DOM"
Case Else
End Select
End Sub

If you want it to run automatically when a cell is changed, use the
Change event instead. In the worksheet's code module, use

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case UCase(Left(Range("D2").Text, 2))
Case "00", "11", "CA"
Application.EnableEvents = False
Application.Intersect(Me.UsedRange, _
Range("E2").EntireColumn).Value = "INTL"
Range("E2").Value = "DOM"
Application.EnableEvents = True
Case Else
End Select
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com




On Mon, 22 Feb 2010 11:15:07 -0800, "dizzl3e"
wrote:

I am trying to automate a process on a spreadsheet. Where Cell D2 begins
with "00" or "11" or "CA" then Cell E2="DOM". Once its run its process
then
I want it to label everything else on column E "INTL". Any help is
greatly
appreciated. thanks.