我目前有这个If MsgBox声明。如果选择了vbYes,它将编辑单元格H8,如果选择了vbNo,它将编辑下面的单元格3(H11)。
from folium import plugins
from folium.plugins import HeatMap
from folium.plugins import MarkerCluster
import pandas as pd
map = folium.Map(location=[lat, long],zoom_start =12)
data = pd.read_csv(filename)
# List comprehension to make out list of lists
heat_data = [[row['LAT'],row['LONG'],] for index, row in data.iterrows()]
# Plot it on the map
HeatMap(heat_data).add_to(map)
# Display the map
map
map.save('C:\Temp\map2.html')
编辑是相同的 - 唯一的区别是单元格向下偏移3个单元格。在这个例子中,我只使用H8和H9,但在我的数据中,还有更多的单元正在更新。这使我的代码混乱。有没有简单的方法来巩固这个?
答案 0 :(得分:3)
'Make a range first
Set WorkingRange = '(YourRangeHere)'
If MsgBox("Is X? ", vbYesNo, "Confirm") = vbNo Then
Set WorkingRange = WorkingRange.Offset(3)
End If
'Do this with WorkingRange here
答案 1 :(得分:1)
Dim i as Long, j as string
i = 8
j = "Whatever edit is"
If MsgBox("Is X? ", vbYesNo, "Confirm") = vbYes Then
Cells(i, "H").Value = j 'if Yes
Else
Cells(i+3, "H").Value = j 'if No
End If
如果你想为不同的值循环i,这将非常快。
For i = 8 to 200 Step 1
'do soemthing using i
Next i