Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Looping and Testing Cell Values



I am using VBA and Oracle Objects for OLE to query an Oracle database
and pull values into a spreadsheet. I have to test the values of cells
in two columns of data and based on the contents of these values
insert a value into a third column.

For example:

If the value in Cell F2 = 'A' AND the value in Cell G2 = 1 THEN insert
the value 'V1' into Cell H2

If the value in Cell F2 = 'A' AND the value in Cell G2 = 2 THEN insert
the value 'V3' into Cell H2

etc.

Here are the actual combinations:

Value1 Value2 Value to Insert

New Trans Abandoned Customer opt out
Regular Abandoned in queue Abandoned
Regular Abandoned while ringing agent Abandoned
Conf/Trans All other cases Transfer to CCT
Regular All other cases Handled by CSR
Transfer All other cases Transfer to CCT
Conference Call disconnected by agent Handled by CSR
Regular Call disconnected by agent Handled by CSR
Emergency Call disconnected by agent Handled by CSR
Conference Call disconnected by caller Handled by CSR
Regular Call disconnected by caller Handled by CSR
Conf/Trans Terminated by transfer Transfer to extension

Can someone please help me with the code to loop through the two
columns and test the values and populate the third column. Everything
I try keeps blowing up. Right now I am running into a dead end with
populating a two dimensional array. I think this method is not the
easiest. Help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Looping and Testing Cell Values

Here is some code for you. I was not sure if by v1 you meant value 1 or the
value in cell V1. I went with the value in V1.

Public Sub Poplulate()
Dim rng As Range
Dim wks As Worksheet

Set wks = ActiveSheet
Set rng = wks.Range("F65536").End(xlUp)

Do While rng.Row 1
Select Case rng.Value
Case "A"
Select Case rng.Offset(0, 1).Value
Case 1
rng.Offset(0, 2).Value = wks.Range("V1").Value
Case 2
rng.Offset(0, 2).Value = wks.Range("V2").Value
Case Else
rng.Offset(0, 2).Value = wks.Range("V5").Value
End Select
Case "B"
Select Case rng.Offset(0, 1).Value
Case 1
rng.Offset(0, 2).Value = wks.Range("V3").Value
Case 2
rng.Offset(0, 2).Value = wks.Range("V4").Value
Case Else
rng.Offset(0, 2).Value = wks.Range("V5").Value
End Select
Case Else
rng.Offset(0, 2).Value = wks.Range("V5").Value
End Select
Set rng = rng.Offset(-1, 0)
Loop
End Sub

--
HTH...

Jim Thomlinson


" wrote:



I am using VBA and Oracle Objects for OLE to query an Oracle database
and pull values into a spreadsheet. I have to test the values of cells
in two columns of data and based on the contents of these values
insert a value into a third column.

For example:

If the value in Cell F2 = 'A' AND the value in Cell G2 = 1 THEN insert
the value 'V1' into Cell H2

If the value in Cell F2 = 'A' AND the value in Cell G2 = 2 THEN insert
the value 'V3' into Cell H2

etc.

Here are the actual combinations:

Value1 Value2 Value to Insert

New Trans Abandoned Customer opt out
Regular Abandoned in queue Abandoned
Regular Abandoned while ringing agent Abandoned
Conf/Trans All other cases Transfer to CCT
Regular All other cases Handled by CSR
Transfer All other cases Transfer to CCT
Conference Call disconnected by agent Handled by CSR
Regular Call disconnected by agent Handled by CSR
Emergency Call disconnected by agent Handled by CSR
Conference Call disconnected by caller Handled by CSR
Regular Call disconnected by caller Handled by CSR
Conf/Trans Terminated by transfer Transfer to extension

Can someone please help me with the code to loop through the two
columns and test the values and populate the third column. Everything
I try keeps blowing up. Right now I am running into a dead end with
populating a two dimensional array. I think this method is not the
easiest. Help!

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
HELP, PLEASE - Testing Multiple Values wingale Excel Discussion (Misc queries) 4 April 14th 06 10:52 PM
Faster Way of looping through cell values Andibevan Excel Discussion (Misc queries) 1 August 12th 05 03:10 PM
Testing Values of Cells [email protected] Excel Programming 5 July 20th 05 05:36 PM
Testing a string array for any values Chris W. Excel Programming 9 March 21st 05 02:13 PM
Testing cell values... Kevin Excel Programming 0 September 29th 03 06:59 PM


All times are GMT +1. The time now is 08:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"