If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
array data type
Hi, I'm trying to take a column of integers and input them into an array
which I can then use for a loop instead of using this format: If (Worksheets("NeeleyNedPRE").Cells(pRow, pCol).Value = 0) Then For some reason this doesn't work because the column selected all resets to zero rather than running the loop correctly and I think that an arrray might be the only option. What the easiest way to solve this problem? -Andrew --- Message posted from http://www.ExcelForum.com/ |
#2
|
|||
|
|||
array data type
anjem wrote:
Hi, I'm trying to take a column of integers and input them into an array which I can then use for a loop instead of using this format: If (Worksheets("NeeleyNedPRE").Cells(pRow, pCol).Value = 0) Then For some reason this doesn't work because the column selected all resets to zero rather than running the loop correctly and I think that an arrray might be the only option. What the easiest way to solve this problem? -Andrew --- Message posted from http://www.ExcelForum.com/ Post the troubling code. Alan Beban |
#3
|
|||
|
|||
array data type
Dim xDataArray(10940) As Integer
Dim rowCount As Integer For rowCount = 21 To 10940 Worksheets("NeeleyNedPRE").Range("I" & rowCount).Value = xDataArray(rowCount) Next rowCount Dim Check As Boolean Check = True Dim xArray(10940) As Integer Dim xCount As Integer xCount = 0 Dim pRow, pCol As Integer pRow = 21 pCol = 12 Do Do While i 10920 If (Worksheets("NeeleyNedPRE").Range("L" & pCol).Value = 0) Then xCount = xCount + 1 pRow = pRow + 1 i = i + 1 xArray(i) = xCount Else pRow = 0 pCol = pRow + 1 i = i + 1 xArray(i) = xCount End If Loop Check = False Loop Until Check = False --- Message posted from http://www.ExcelForum.com/ |
#4
|
|||
|
|||
array data type
After Dim xDataArray(10940) As Integer, xDataArray is a one-dimensional
array with all elements equal to 0. What are you expecting Worksheets("NeeleyNedPRE").Range("I" & rowCount).Value = xDataArray(rowCount) to do? (It is simply setting all the values in I21:I10940 to 0.) Alan Beban anjem wrote: Dim xDataArray(10940) As Integer Dim rowCount As Integer For rowCount = 21 To 10940 Worksheets("NeeleyNedPRE").Range("I" & rowCount).Value = xDataArray(rowCount) Next rowCount Dim Check As Boolean Check = True Dim xArray(10940) As Integer Dim xCount As Integer xCount = 0 Dim pRow, pCol As Integer pRow = 21 pCol = 12 Do Do While i 10920 If (Worksheets("NeeleyNedPRE").Range("L" & pCol).Value = 0) Then xCount = xCount + 1 pRow = pRow + 1 i = i + 1 xArray(i) = xCount Else pRow = 0 pCol = pRow + 1 i = i + 1 xArray(i) = xCount End If Loop Check = False Loop Until Check = False --- Message posted from http://www.ExcelForum.com/ |
Thread Tools | |
Display Modes | |
|
|