忽略循环VBA中的隐藏行

忽略循环VBA中的隐藏行,vba,loops,Vba,Loops,我有这个代码,可以获取股票价格。所有股票符号都在一个表列表中,现在如果该符号不在观察列表中,其行将被隐藏。我现在面临的挑战或我想要实现的是忽略这些隐藏的行来获取其股票价格。我只是想让代码忽略它。 提前谢谢你的帮助 当前的结果是,那些不在观察列表中的是隐藏行,但代码仍然返回其价格: 行符号价格监视列表过滤器 1 ABS 17是的 'Last row find lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row Set rng = ws.Range(

我有这个代码,可以获取股票价格。所有股票符号都在一个表列表中,现在如果该符号不在观察列表中,其行将被隐藏。我现在面临的挑战或我想要实现的是忽略这些隐藏的行来获取其股票价格。我只是想让代码忽略它。 提前谢谢你的帮助

当前的结果是,那些不在观察列表中的是隐藏行,但代码仍然返回其价格:

行符号价格监视列表过滤器

1 ABS 17是的

'Last row find
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

Set rng = ws.Range("A6:A" & lastrow)

'Clear Prior Prices
ws.Range("H6:I" & lastrow).ClearContents

n = 6
'Get Symbols list

For Each x In rng

symbol = x


Set myrequest = CreateObject("WinHttp.WinHttpRequest.5.1")
myrequest.Open "Get", "http://phisix-api.appspot.com/stocks/" & symbol & ".json"
On Error Resume Next
myrequest.Send


If myrequest.ResponseText = "" Then

 i = 0
 ws.Range(Cells(n, 8), Cells(n, 8)) = i
 ws.Range(Cells(n, 9), Cells(n, 9)) = i


 Else

  Dim Json As Object
  Set Json = JsonConverter.ParseJson(myrequest.ResponseText)
    i = Json("stock")(1)("price")("amount")
    ws.Range(Cells(n, 8), Cells(n, 8)) = i
    i = Json("stock")(1)("percent_change") / 100
     ws.Range(Cells(n, 9), Cells(n, 9)) = i


 End If

n = n + 1

Next x
2 BDO 19号

3 NIKL 4是的

'Last row find
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

Set rng = ws.Range("A6:A" & lastrow)

'Clear Prior Prices
ws.Range("H6:I" & lastrow).ClearContents

n = 6
'Get Symbols list

For Each x In rng

symbol = x


Set myrequest = CreateObject("WinHttp.WinHttpRequest.5.1")
myrequest.Open "Get", "http://phisix-api.appspot.com/stocks/" & symbol & ".json"
On Error Resume Next
myrequest.Send


If myrequest.ResponseText = "" Then

 i = 0
 ws.Range(Cells(n, 8), Cells(n, 8)) = i
 ws.Range(Cells(n, 9), Cells(n, 9)) = i


 Else

  Dim Json As Object
  Set Json = JsonConverter.ParseJson(myrequest.ResponseText)
    i = Json("stock")(1)("price")("amount")
    ws.Range(Cells(n, 8), Cells(n, 8)) = i
    i = Json("stock")(1)("percent_change") / 100
     ws.Range(Cells(n, 9), Cells(n, 9)) = i


 End If

n = n + 1

Next x
4技术5号

5 MWC 10是

'Last row find
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

Set rng = ws.Range("A6:A" & lastrow)

'Clear Prior Prices
ws.Range("H6:I" & lastrow).ClearContents

n = 6
'Get Symbols list

For Each x In rng

symbol = x


Set myrequest = CreateObject("WinHttp.WinHttpRequest.5.1")
myrequest.Open "Get", "http://phisix-api.appspot.com/stocks/" & symbol & ".json"
On Error Resume Next
myrequest.Send


If myrequest.ResponseText = "" Then

 i = 0
 ws.Range(Cells(n, 8), Cells(n, 8)) = i
 ws.Range(Cells(n, 9), Cells(n, 9)) = i


 Else

  Dim Json As Object
  Set Json = JsonConverter.ParseJson(myrequest.ResponseText)
    i = Json("stock")(1)("price")("amount")
    ws.Range(Cells(n, 8), Cells(n, 8)) = i
    i = Json("stock")(1)("percent_change") / 100
     ws.Range(Cells(n, 9), Cells(n, 9)) = i


 End If

n = n + 1

Next x
我想要实现的是,代码只忽略那些隐藏在获取股票价格中的股票/行

行符号价格监视列表过滤器

1 ABS 17是的

'Last row find
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

Set rng = ws.Range("A6:A" & lastrow)

'Clear Prior Prices
ws.Range("H6:I" & lastrow).ClearContents

n = 6
'Get Symbols list

For Each x In rng

symbol = x


Set myrequest = CreateObject("WinHttp.WinHttpRequest.5.1")
myrequest.Open "Get", "http://phisix-api.appspot.com/stocks/" & symbol & ".json"
On Error Resume Next
myrequest.Send


If myrequest.ResponseText = "" Then

 i = 0
 ws.Range(Cells(n, 8), Cells(n, 8)) = i
 ws.Range(Cells(n, 9), Cells(n, 9)) = i


 Else

  Dim Json As Object
  Set Json = JsonConverter.ParseJson(myrequest.ResponseText)
    i = Json("stock")(1)("price")("amount")
    ws.Range(Cells(n, 8), Cells(n, 8)) = i
    i = Json("stock")(1)("percent_change") / 100
     ws.Range(Cells(n, 9), Cells(n, 9)) = i


 End If

n = n + 1

Next x
2号BDO

3 NIKL 4是的

'Last row find
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

Set rng = ws.Range("A6:A" & lastrow)

'Clear Prior Prices
ws.Range("H6:I" & lastrow).ClearContents

n = 6
'Get Symbols list

For Each x In rng

symbol = x


Set myrequest = CreateObject("WinHttp.WinHttpRequest.5.1")
myrequest.Open "Get", "http://phisix-api.appspot.com/stocks/" & symbol & ".json"
On Error Resume Next
myrequest.Send


If myrequest.ResponseText = "" Then

 i = 0
 ws.Range(Cells(n, 8), Cells(n, 8)) = i
 ws.Range(Cells(n, 9), Cells(n, 9)) = i


 Else

  Dim Json As Object
  Set Json = JsonConverter.ParseJson(myrequest.ResponseText)
    i = Json("stock")(1)("price")("amount")
    ws.Range(Cells(n, 8), Cells(n, 8)) = i
    i = Json("stock")(1)("percent_change") / 100
     ws.Range(Cells(n, 9), Cells(n, 9)) = i


 End If

n = n + 1

Next x
4技术编号

5 MWC 10是

'Last row find
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

Set rng = ws.Range("A6:A" & lastrow)

'Clear Prior Prices
ws.Range("H6:I" & lastrow).ClearContents

n = 6
'Get Symbols list

For Each x In rng

symbol = x


Set myrequest = CreateObject("WinHttp.WinHttpRequest.5.1")
myrequest.Open "Get", "http://phisix-api.appspot.com/stocks/" & symbol & ".json"
On Error Resume Next
myrequest.Send


If myrequest.ResponseText = "" Then

 i = 0
 ws.Range(Cells(n, 8), Cells(n, 8)) = i
 ws.Range(Cells(n, 9), Cells(n, 9)) = i


 Else

  Dim Json As Object
  Set Json = JsonConverter.ParseJson(myrequest.ResponseText)
    i = Json("stock")(1)("price")("amount")
    ws.Range(Cells(n, 8), Cells(n, 8)) = i
    i = Json("stock")(1)("percent_change") / 100
     ws.Range(Cells(n, 9), Cells(n, 9)) = i


 End If

n = n + 1

Next x
你可以试试下面的方法

'Last row find
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row

Set rng = ws.Range("A6:A" & lastrow)

'Clear Prior Prices
ws.Range("H6:I" & lastrow).ClearContents

n = 6
'Get Symbols list

For Each x In rng

If x.entirerow.Hidden = false then
symbol = x

Set myrequest = CreateObject("WinHttp.WinHttpRequest.5.1")
myrequest.Open "Get", "http://phisix-api.appspot.com/stocks/" & symbol & ".json"
On Error Resume Next
myrequest.Send


If myrequest.ResponseText = "" Then  
 i = 0
 ws.Range(Cells(n, 8), Cells(n, 8)) = i
 ws.Range(Cells(n, 9), Cells(n, 9)) = i

 Else

  Dim Json As Object
  Set Json = JsonConverter.ParseJson(myrequest.ResponseText)
    i = Json("stock")(1)("price")("amount")
    ws.Range(Cells(n, 8), Cells(n, 8)) = i
    i = Json("stock")(1)("percent_change") / 100
     ws.Range(Cells(n, 9), Cells(n, 9)) = i
 End If  
End if
n = n + 1

Next x

如果x.entirerow.Hidden=false thenHi Scott,我可以知道建议的代码应该放在哪里吗?