Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() hi there im having trouble with adding values to a cell and linking them to my arrays. basicly what i want to do is input the number from 1-5 into cell F12, this representing a vote for a radio program. once the number 1-5 has been put into the cell i then want to add the integer one to the corrisponding cell for that radio programe that i have created. but im having alot of trouble doing this. i can get one to be added to the first cell in my table if i put < in but this is not what i want. i want the number be to be loked up in the array and then 1 to be added onto the score each time. the below is the coding that i have done so far, please can someone help me it is driving me around the bend, because i am new to VBA programming and im having alot of trouble understanding it all. Private Sub Submit_Click() Dim radioProgramName(5) As String, radioProgramNumber(5) As Single Dim submitScore As Integer radioProgramName(1) = "talk sport" radioProgramName(2) = "talk garden" radioProgramName(3) = "talk DIY" radioProgramName(4) = "talk talk" radioProgramName(5) = "talk weather" radioProgramNumber(1) = 1 radioProgramNumber(2) = 2 radioProgramNumber(3) = 3 radioProgramNumber(4) = 4 radioProgramNumber(5) = 5 'this is another way of holding the data in an array i think but i am not sure so i have done it the other way below too. 'radioProgramName(5) = Array("talk sport", "talk garden", "talk DIY", "talk talk", "talk weather") 'radioProgramNumber(5) = Array("54", "98", "45", "63", "30") If Range("f12").Select = "1" Then submitScore = Range("f12").Value = Range("d12").Value Range("d12").Value = Range("d12").Value + 1 End If If Range("f12").Select = "2" Then submitScore = Range("f12").Value = Range("d13").Value Range("d13").Value = Range("d13").Value + 1 End If If Range("f12").Select = "3" Then submitScore = Range("f12").Value = Range("d14").Value Range("d14").Value = Range("d14").Value + 1 End If If Range("f12").Select = "4" Then submitScore = Range("f12").Value = Range("d15").Value Range("d15").Value = Range("d15").Value + 1 End If If Range("f12").Select = "5" Then submitScore = Range("f12").Value = Range("d16").Value Range("d16").Value = Range("d16").Value + 1 End If End Sub -- RELWOD85 ------------------------------------------------------------------------ RELWOD85's Profile: http://www.excelforum.com/member.php...o&userid=25753 View this thread: http://www.excelforum.com/showthread...hreadid=393046 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I compare values in two arrays in Excel? | Excel Discussion (Misc queries) | |||
retrieve duplicate values from arrays | Excel Discussion (Misc queries) | |||
Using CORREL with arrays containing null values | Excel Discussion (Misc queries) | |||
Storing values to arrays for subsequent use | Excel Programming | |||
Ranges and Arrays - Passing values | Excel Programming |