如何在我的数组中添加超过200个值?

huangapple go评论83阅读模式
英文:

How to add more than 200+ values in my array?

问题

以下是您提供的VBA代码的中文翻译部分:

  1. Sub CopyDataByCity()
  2. Dim sourceSheet As Worksheet
  3. Dim targetSheet As Worksheet
  4. Dim lastRow As Long
  5. Dim i As Long
  6. Dim citiesToFilter() As Variant
  7. Dim city As Variant
  8. Dim headerRow As Range
  9. Dim currentRow As Long
  10. ' 设置源工作表
  11. Set sourceSheet = ThisWorkbook.Sheets("Portfolio Summary")
  12. ' 设置目标工作表
  13. Set targetSheet = ThisWorkbook.Sheets("RAW DATA")
  14. ' 定义要按顺序筛选的城市列表
  15. citiesToFilter = Array("Jacksonville, FL", "Houston-The Woodlands-Sugar Land, TX", "Seattle-Tacoma-Bellevue, WA", "Minneapolis-St. Paul-Bloomington, MN-WI", "San Antonio-New Braunfels, TX", "Portland-Vancouver-Hillsboro, OR-WA", "Philadelphia-Camden-Wilmington, PA-NJ-DE-MD", "Boston-Cambridge-Newton, MA-NH", "Nashville-Davidson--Murfreesboro--Franklin, TN", "Columbus, OH", "Indianapolis-Carmel-Anderson, IN", "Raleigh-Cary, NC", "Cincinnati, OH-KY-IN", "Richmond, VA", "Urban Honolulu, HI", "Greensboro-High Point, NC", "Sacramento-Roseville-Folsom, CA", "Colorado Springs, CO", "Stockton, CA", "San Jose-Sunnyvale-Santa Clara, CA", "Harrisburg-Carlisle, PA", "San Francisco-Oakland-Berkeley, CA", "Louisville/Jefferson County, KY-IN", "Reno, NV", "Lakeland-Winter Haven, FL", "San Diego-Chula Vista-Carlsbad, CA", "Fort Collins, CO", "Salt Lake City, UT", "Boulder, CO", "Kansas City, MO-KS", "Baltimore-Columbia-Towson, MD", "Memphis, TN-MS-AR", "Tallahassee, FL", "North Port-Sarasota-Bradenton, FL", "Tucson, AZ")
  16. ' 查找源工作表中的最后一行数据
  17. lastRow = sourceSheet.Cells(Rows.Count, "A").End(xlUp).Row
  18. ' 获取标题行
  19. Set headerRow = sourceSheet.Range("6:6")
  20. ' 设置目标工作表中的起始行
  21. currentRow = 2 ' 假设标题行在第1行
  22. ' 遍历要按顺序筛选的城市
  23. For Each city In citiesToFilter
  24. ' 遍历源工作表中的行
  25. For i = 8 To lastRow ' 假设标题行在第7
  26. ' 检查列Q中的城市名称是否与当前城市匹配
  27. If sourceSheet.Cells(i, "Q").Value = city Then
  28. ' 如果城市名称匹配,复制指定的列并粘贴到目标工作表中
  29. targetSheet.Range("A" & currentRow).Value = sourceSheet.Cells(i, "C").Value ' 复制列
  30. targetSheet.Range("B" & currentRow).Value = sourceSheet.Cells(i, "H").Value ' 复制列
  31. targetSheet.Range("C" & currentRow).Value = sourceSheet.Cells(i, "D").Value ' 复制列
  32. targetSheet.Range("D" & currentRow).Value = sourceSheet.Cells(i, "S").Value ' 复制列
  33. targetSheet.Range("E" & currentRow).Value = sourceSheet.Cells(i, "I").Value ' 复制列
  34. targetSheet.Range("F" & currentRow).Value = sourceSheet.Cells(i, "R").Value ' 复制列
  35. targetSheet.Range("G" & currentRow).Value = sourceSheet.Cells(i, "W").Value ' 复制列
  36. targetSheet.Range("H" & currentRow).Value = sourceSheet.Cells(i, "N").Value ' 复制列
  37. targetSheet.Cells(currentRow, "I").Value = city ' 将城市名称粘贴到目标工作表中的列I
  38. currentRow = currentRow + 1 ' 增加当前行变量
  39. End If
  40. ' 检查下一行是否为空或城市是否更改
  41. If sourceSheet.Cells(i + 1, "A").Value = "" Or sourceSheet.Cells(i + 1, "Q").Value <> city Then
  42. ' 如果下一行为空或城市更改,跳过它
  43. i = i + 1
  44. End If
  45. Next i
  46. Next city
  47. End Sub

希望这个翻译对您有所帮助。如果您需要进一步的帮助,请随时提问。

英文:

I'm trying to use one VBA code which filters the city and paste the data accordingly in another sheet with reference to some column names

I'm trying to make a long list in array but it not taking more than 35 values.

The mentioned code

  1. Sub CopyDataByCity()
  2. Dim sourceSheet As Worksheet
  3. Dim targetSheet As Worksheet
  4. Dim lastRow As Long
  5. Dim i As Long
  6. Dim citiesToFilter() As Variant
  7. Dim city As Variant
  8. Dim headerRow As Range
  9. Dim currentRow As Long
  10. &#39; Set the source sheet
  11. Set sourceSheet = ThisWorkbook.Sheets(&quot;Portfolio Summary&quot;)
  12. &#39; Set the target sheet
  13. Set targetSheet = ThisWorkbook.Sheets(&quot;RAW DATA&quot;)
  14. &#39; Define the list of cities to filter on in the desired order
  15. citiesToFilter = Array(&quot;Jacksonville, FL&quot;, &quot;Houston-The Woodlands-Sugar Land, TX&quot;, &quot;Seattle-Tacoma-Bellevue, WA&quot;, &quot;Minneapolis-St. Paul-Bloomington, MN-WI&quot;, &quot;San Antonio-New Braunfels, TX&quot;, &quot;Portland-Vancouver-Hillsboro, OR-WA&quot;, &quot;Philadelphia-Camden-Wilmington, PA-NJ-DE-MD&quot;, &quot;Boston-Cambridge-Newton, MA-NH&quot;, &quot;Nashville-Davidson--Murfreesboro--Franklin, TN&quot;, &quot;Columbus, OH&quot;, &quot;Indianapolis-Carmel-Anderson, IN&quot;, &quot;Raleigh-Cary, NC&quot;, &quot;Cincinnati, OH-KY-IN&quot;, &quot;Richmond, VA&quot;, &quot;Urban Honolulu, HI&quot;, &quot;Greensboro-High Point, NC&quot;, &quot;Sacramento-Roseville-Folsom, CA&quot;, &quot;Colorado Springs, CO&quot;, &quot;Stockton, CA&quot;, &quot;San Jose-Sunnyvale-Santa Clara, CA&quot;, &quot;Harrisburg-Carlisle, PA&quot;, &quot;San Francisco-Oakland-Berkeley, CA&quot;, &quot;Louisville/Jefferson County, KY-IN&quot;, &quot;Reno, NV&quot;, &quot;Lakeland-Winter Haven, FL&quot;, &quot;San Diego-Chula Vista-Carlsbad, CA&quot;, &quot;Fort Collins, CO&quot;, &quot;Salt Lake City, UT&quot;, &quot;Boulder, CO&quot;, &quot;Kansas City, MO-KS&quot;, &quot;Baltimore-Columbia-Towson, MD&quot;, &quot;Memphis, TN-MS-AR&quot;, &quot;Tallahassee, FL&quot;, &quot;North Port-Sarasota-Bradenton, FL&quot;, &quot;Tucson, AZ&quot;)
  16. &#39; Find the last row of data in the source sheet
  17. lastRow = sourceSheet.Cells(Rows.Count, &quot;A&quot;).End(xlUp).Row
  18. &#39; Get the header row
  19. Set headerRow = sourceSheet.Range(&quot;6:6&quot;)
  20. &#39; Set the starting row in the target sheet
  21. currentRow = 2 &#39; Assuming the header row is in row 1
  22. &#39; Loop through the cities to filter on in the desired order
  23. For Each city In citiesToFilter
  24. &#39; Loop through the rows in the source sheet
  25. For i = 8 To lastRow &#39; Assuming the header row is in row 7
  26. &#39; Check if the city name in column Q matches the current city
  27. If sourceSheet.Cells(i, &quot;Q&quot;).Value = city Then
  28. &#39; If the city name matches, copy the specified columns and paste into the target sheet
  29. targetSheet.Range(&quot;A&quot; &amp; currentRow).Value = sourceSheet.Cells(i, &quot;C&quot;).Value &#39; Copy column
  30. targetSheet.Range(&quot;B&quot; &amp; currentRow).Value = sourceSheet.Cells(i, &quot;H&quot;).Value &#39; Copy column
  31. targetSheet.Range(&quot;C&quot; &amp; currentRow).Value = sourceSheet.Cells(i, &quot;D&quot;).Value &#39; Copy column
  32. targetSheet.Range(&quot;D&quot; &amp; currentRow).Value = sourceSheet.Cells(i, &quot;S&quot;).Value &#39; Copy column
  33. targetSheet.Range(&quot;E&quot; &amp; currentRow).Value = sourceSheet.Cells(i, &quot;I&quot;).Value &#39; Copy column
  34. targetSheet.Range(&quot;F&quot; &amp; currentRow).Value = sourceSheet.Cells(i, &quot;R&quot;).Value &#39; Copy column
  35. targetSheet.Range(&quot;G&quot; &amp; currentRow).Value = sourceSheet.Cells(i, &quot;W&quot;).Value &#39; Copy column
  36. targetSheet.Range(&quot;H&quot; &amp; currentRow).Value = sourceSheet.Cells(i, &quot;N&quot;).Value &#39; Copy column
  37. targetSheet.Cells(currentRow, &quot;I&quot;).Value = city &#39; Paste the city name to column I in the target sheet
  38. currentRow = currentRow + 1 &#39; Increment the current row variable
  39. End If
  40. &#39; Check if the next row is blank or if the city changes
  41. If sourceSheet.Cells(i + 1, &quot;A&quot;).Value = &quot;&quot; Or sourceSheet.Cells(i + 1, &quot;Q&quot;).Value &lt;&gt; city Then
  42. &#39; If the next row is blank or if the city changes, skip over it
  43. i = i + 1
  44. End If
  45. Next i
  46. Next city
  47. End Sub

答案1

得分: 9

a) 数组的元素数量没有35个的限制。您达到了VBA编辑器代码行的最大长度限制(1024个字符)。

b) 您可以通过在行末使用续行符号并在下一行继续编写来避免长度限制:

  1. citiesToFilter = Array("Jacksonville, FL", "Houston-The Woodlands-Sugar Land, TX", _
  2. "Seattle-Tacoma-Bellevue, WA", (...))

然而,您还有一个可以组合的行数限制,最多为25行,所以也可能会达到限制。

c) 您应该使用一个函数来获取城市列表,以便将程序逻辑和筛选值的创建分开。请记住,此列表可能会更改,或者某个名称可能有错拼,您将很难在代码中找到正确的位置。也许可以这样做:

  1. Function getCityList() As String()
  2. Dim cityList(1 To 200) As String
  3. cityList(1) = "Jacksonville, FL"
  4. cityList(2) = "Houston-The Woodlands-Sugar Land, TX"
  5. cityList(3) = "Seattle-Tacoma-Bellevue, WA"
  6. (...)
  7. getCityList = cityList
  8. End Function

d) 不要在VBA代码中硬编码列表,最好将列表放在工作表中。如果您不希望用户看到该列表,只需将其隐藏。以下代码假定您有一个名为"CityList"的工作表,其中有一个命名范围"CityList"。如果您可以接受列表是一个二维数组(您需要更改For Each city In citiesToFilter语句):

  1. Function getCityList() As Variant
  2. Dim cityList
  3. cityList = ThisWorkbook.Sheets("CityList").Range("CityList").Value
  4. getCityList = cityList
  5. End Function

如果您更喜欢有一个一维数组,只需将其转换:

  1. Function getCityList() As String()
  2. Dim sheetValues As Variant, i As Long
  3. sheetValues = ThisWorkbook.Sheets("CityList").Range("CityList").Value
  4. ReDim cityList(1 To UBound(sheetValues, 1)) As String
  5. For i = 1 To UBound(sheetValues, 1)
  6. cityList(i) = sheetValues(i, 1)
  7. Next
  8. getCityList = cityList
  9. End Function
英文:

a) There is no limit of 35 elements for an array. You are reaching the maximum length of a code line of the VBA editor (1024 characters).

b) You can avoid that length limit by using line continue character at the end of the line and continue on the next line:

  1. citiesToFilter = Array(&quot;Jacksonville, FL&quot;, &quot;Houston-The Woodlands-Sugar Land, TX&quot;, _
  2. &quot;Seattle-Tacoma-Bellevue, WA&quot;, (...)

However, there is also a limit of 25 lines that you can combine with that, so you might reach a limit there also.

c) You should use a function to get the list of cities so that you separate the program logic and the creation of the filter values. Have in mind that this list might change or you have a typo in one of the names and you will have a hard time to find the correct place in your code. Maybe something like that:

  1. Function getCityList() As String()
  2. Dim cityList(1 to 200) as String
  3. cityList(1) = &quot;Jacksonville, FL&quot;
  4. cityList(2) = &quot;Houston-The Woodlands-Sugar Land, TX&quot;
  5. cityList(3) = &quot;Seattle-Tacoma-Bellevue, WA&quot;
  6. (...)
  7. getCityList = cityList
  8. End Function

d) Instead of hard code the list in your VBA code, I guess it's a much better idea to have the list in a sheet. If you don't want the user to see that list, just hide it. The following code assumes that you have a sheet "CityList" with a named range "CityList"). If you can live with the fact that the list is a 2-dimensional array (you will need to change the For Each city In citiesToFilter statement)

  1. Function getCityList() As Variant
  2. Dim cityList
  3. cityList= ThisWorkbook.Sheets(&quot;CityList&quot;).Range(&quot;CityList&quot;).Value
  4. getCityList = cityList
  5. End Function

If you prefer to have a one-dimensional array, just convert it:

  1. Function getCityList() As String()
  2. Dim sheetValues As Variant, i As Long
  3. sheetValues = ThisWorkbook.Sheets(&quot;CityList&quot;).Range(&quot;CityList&quot;).Value
  4. ReDim cityList(1 To UBound(sheetValues, 1)) As String
  5. For i = 1 To UBound(sheetValues, 1)
  6. cityList(i) = sheetValues(i, 1)
  7. Next
  8. getCityList = cityList
  9. End Function

答案2

得分: 0

根据您的要求,以下是代码部分的中文翻译:

如果我理解您正确...

在sourceSheet中,从第8行开始(第7行是标题),从列A到Z的数据。从第8行开始,直到citiesToFilter中提到的城市名的列Q中的数据。

在targetSheet中,除了A1:H1中的标题(8列)之外,没有数据。

以下的代码是根据上述说明运行的。

预期结果是,在sourceSheet列Q中找到的每个城市单元格的每一行(其条件来自于对citiesToFilter中的每个元素的循环),将找到的城市行的值依次放入targetSheet列A到H,而行是具有数据的最后一行 +1。

  1. Sub test()
  2. Dim sourceSheet As Worksheet, targetSheet As Worksheet
  3. Dim rgS As Range, rgT As Range, rgR As Range
  4. Dim citiesToFilter, el, arrCol, col
  5. Set sourceSheet = ThisWorkbook.Sheets("Portfolio Summary")
  6. Set rgS = sourceSheet.Range("Q8", sourceSheet.Range("Q" & Rows.Count).End(xlUp))
  7. Set targetSheet = ThisWorkbook.Sheets("RAW DATA")
  8. Set rgT = targetSheet.Range("A2")
  9. citiesToFilter = Array("Jacksonville, FL", "Houston-The Woodlands-Sugar Land, TX", "Seattle-Tacoma-Bellevue, WA", "Minneapolis-St. Paul-Bloomington, MN-WI", "San Antonio-New Braunfels, TX", "Portland-Vancouver-Hillsboro, OR-WA", "Philadelphia-Camden-Wilmington, PA-NJ-DE-MD", "Boston-Cambridge-Newton, MA-NH", "Nashville-Davidson--Murfreesboro--Franklin, TN", "Columbus, OH", "Indianapolis-Carmel-Anderson, IN", "Raleigh-Cary, NC", "Cincinnati, OH-KY-IN", "Richmond, VA", "Urban Honolulu, HI", "Greensboro-High Point, NC", "Sacramento-Roseville-Folsom, CA", "Colorado Springs, CO", "Stockton, CA", "San Jose-Sunnyvale-Santa Clara, CA", "Harrisburg-Carlisle, PA", "San Francisco-Oakland-Berkeley, CA", "Louisville/Jefferson County, KY-IN", "Reno, NV", "Lakeland-Winter Haven, FL", "San Diego-Chula Vista-Carlsbad, CA", "Fort Collins, CO", "Salt Lake City, UT", "Boulder, CO", "Kansas City, MO-KS", "Baltimore-Columbia-Towson, MD", "Memphis, TN-MS-AR", "Tallahassee, FL", "North Port-Sarasota-Bradenton, FL", "Tucson, AZ")
  10. arrCol = Array("C", "H", "D", "S", "I", "R", "W", "N")
  11. For Each el In citiesToFilter
  12. With rgS
  13. If .Find(el, lookat:=xlWhole) Is Nothing Then GoTo nxtEL:
  14. .Replace el, True, xlWhole, , False, , False, False
  15. Set rgR = .SpecialCells(xlConstants, xlLogical)
  16. .Replace True, el, xlWhole, , False, , False, False
  17. End With
  18. For Each cell In rgR
  19. For Each col In arrCol
  20. rgT.Value = sourceSheet.Range(col & cell.Row).Value
  21. Set rgT = rgT.Offset(0, 1)
  22. Next
  23. Set rgT = rgT.Offset(1, 0).End(xlToLeft)
  24. Next
  25. nxtEL:
  26. Next el
  27. End Sub

rgS是sourceSheet中城市数据的范围,从Q8开始,到任何行结束。
rgT是要填充的targetSheet的起始单元格。
arrCol是期望的源列数组,要放入目标表格中。

有3个循环,
A. 对于citiesToFilter中的每个元素的循环
B. 对于rgS中找到的每个单元格的循环
C. 对于arrCol中的每个列名的循环

A的第一次迭代示例...
"Jacksonville, FL"在sourceSheet的Q10、Q15、Q20中找到。
所以这些单元格(Q10、Q15、Q20)存储在rgR变量中。

现在下一个循环是B,循环到rgR中的每个单元格。
然后进入循环C,循环到arrCol中的每个列,并相应地放置结果。

B的第一个迭代示例,循环的单元格是Q10,其行为10。

因此,在循环C的第一次迭代中,sourceSheet.Range(col & cell.Row)是单元格C10,它将C10的值放入rgT ---》sourceSheet单元格A2的C的值。

在循环C的第二次迭代中,sourceSheet.Range(col & cell.Row)是单元格H10,它将H10的值放入下一个rgT。

以此类推,直到循环C的第8次迭代完成。

接下来,B的下一个迭代,循环的单元格是Q15,其行为15。

因此,在循环C的第一次迭代中,sourceSheet.Range(col & cell.Row)是单元格C15,它将C15的值放入下一个rgT......

依此类推,直到循环B的所有单元格完成。

然后,它继续到citiesToFilter中的下一个元素。希望这有助于理解代码的功能。

英文:

If I understand you correctly...<br>

The data in sourceSheet is from column A to Z starting from row 8 (where row 7 is the header). The data in column Q starting from row 8 to whatever is the city name mentioned in citiesToFilter.

In targetSheet, there is no data, except the header in A1:H1 (8 columns).

The code below is run from the explanation above.

Expected result, to each row of the found city cell in sourceSheet column Q (which criteria is coming from the loop to each element in citiesToFilter), put the value of "C", "H", "D", "S", "I", "R", "W", "N" found row city to targetSheet column A to H respectively which row is the lastrow with data + 1.

  1. Sub test()
  2. Dim sourceSheet As Worksheet, targetSheet As Worksheet
  3. Dim rgS As Range, rgT As Range, rgR As Range
  4. Dim citiesToFilter, el, arrCol, col
  5. Set sourceSheet = ThisWorkbook.Sheets(&quot;Portfolio Summary&quot;)
  6. Set rgS = sourceSheet.Range(&quot;Q8&quot;, sourceSheet.Range(&quot;Q&quot; &amp; Rows.Count).End(xlUp))
  7. Set targetSheet = ThisWorkbook.Sheets(&quot;RAW DATA&quot;)
  8. Set rgT = targetSheet.Range(&quot;A2&quot;)
  9. citiesToFilter = Array(&quot;Jacksonville, FL&quot;, &quot;Houston-The Woodlands-Sugar Land, TX&quot;, &quot;Seattle-Tacoma-Bellevue, WA&quot;, &quot;Minneapolis-St. Paul-Bloomington, MN-WI&quot;, &quot;San Antonio-New Braunfels, TX&quot;, &quot;Portland-Vancouver-Hillsboro, OR-WA&quot;, &quot;Philadelphia-Camden-Wilmington, PA-NJ-DE-MD&quot;, &quot;Boston-Cambridge-Newton, MA-NH&quot;, &quot;Nashville-Davidson--Murfreesboro--Franklin, TN&quot;, &quot;Columbus, OH&quot;, &quot;Indianapolis-Carmel-Anderson, IN&quot;, &quot;Raleigh-Cary, NC&quot;, &quot;Cincinnati, OH-KY-IN&quot;, &quot;Richmond, VA&quot;, &quot;Urban Honolulu, HI&quot;, &quot;Greensboro-High Point, NC&quot;, &quot;Sacramento-Roseville-Folsom, CA&quot;, &quot;Colorado Springs, CO&quot;, &quot;Stockton, CA&quot;, &quot;San Jose-Sunnyvale-Santa Clara, CA&quot;, &quot;Harrisburg-Carlisle, PA&quot;, &quot;San Francisco-Oakland-Berkeley, CA&quot;, &quot;Louisville/Jefferson County, KY-IN&quot;, &quot;Reno, NV&quot;, &quot;Lakeland-Winter Haven, FL&quot;, &quot;San Diego-Chula Vista-Carlsbad, CA&quot;, &quot;Fort Collins, CO&quot;, &quot;Salt Lake City, UT&quot;, &quot;Boulder, CO&quot;, &quot;Kansas City, MO-KS&quot;, &quot;Baltimore-Columbia-Towson, MD&quot;, &quot;Memphis, TN-MS-AR&quot;, &quot;Tallahassee, FL&quot;, &quot;North Port-Sarasota-Bradenton, FL&quot;, &quot;Tucson, AZ&quot;)
  10. arrCol = Array(&quot;C&quot;, &quot;H&quot;, &quot;D&quot;, &quot;S&quot;, &quot;I&quot;, &quot;R&quot;, &quot;W&quot;, &quot;N&quot;)
  11. For Each el In citiesToFilter
  12. With rgS
  13. If .Find(el, lookat:=xlWhole) Is Nothing Then GoTo nxtEL:
  14. .Replace el, True, xlWhole, , False, , False, False
  15. Set rgR = .SpecialCells(xlConstants, xlLogical)
  16. .Replace True, el, xlWhole, , False, , False, False
  17. End With
  18. For Each cell In rgR
  19. For Each col In arrCol
  20. rgT.Value = sourceSheet.Range(col &amp; cell.Row).Value
  21. Set rgT = rgT.Offset(0, 1)
  22. Next
  23. Set rgT = rgT.Offset(1, 0).End(xlToLeft)
  24. Next
  25. nxtEL:
  26. Next el
  27. End Sub

rgS is the range of data of city in sourceSheet, starting from Q8 to whatever row.<br>
rgT is the starting cell to fill in targetSheet.<br>
arrCol is the array of the expected column source to be put into target Sheet.<br>

There are 3 loops, <br>
A. loop for each element in citiesToFilter<br>
B. loop for each found cell in rgS<br>
C. loop for each column name in arrCol

Example of the first iteration of A....<br>
"Jacksonville, FL" is found in Q10, Q15, Q20 of sourceSheet.<br>
So those cells (Q10, Q15, Q20) are in rgR variable.

Now the next loop is B, to loop to each cell in rgR <br>
Then go to loop C, to loop to each col in arrCol and put the result accordingly.<br>

Example of the first iteration of B, the looped cell is cell Q10, which row is 10 <br>

So in the first iteration of loop C, sourceSheet.Range(col &amp; cell.Row) is cell C10 , and it put C10 value into rgT ---> sourceSheet cell A2 first iteration of loop C.

In the second iteration of loop C, sourceSheet.Range(col &amp; cell.Row) is cell H10, and it put H10 value into the next rgT.

And so on until the 8th iteration of loop C finish.

The next iteration of loop B, the looped cell is cell Q15, which row is 15.<br>

So in the first iteration of loop C, sourceSheet.Range(col &amp; cell.Row) is cell C15 , and it put C15 value into the next rgT...

In the second iteration of loop C, sourceSheet.Range(col &amp; cell.Row) is cell H15, and it put H15 value into the next rgT.

And so on until the 8th iteration of loop C finish.<br>
And so on until all the cell of loop B finish.<br>
And then it goes to the 2nd element in citiesToFilter.<br>

Sorry, it's difficult for me to explain.

huangapple
  • 本文由 发表于 2023年4月17日 16:01:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76032890.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定