=BDP(F3& " cusip", "security des")
大家好,
我正在尝试编写一个宏,它将上面的确切公式(唯一不同的是F3参考单元格)插入到当前的活动单元格中。下面是实际的vba代码。
我只需要下面的"F3"
单元格来引用每次运行宏时由Excel / vba确定的变量单元格。
我已经有了让vba / Excel确定单元格的代码。让我们说这个变量单元格设置为CName
。所以CName
容纳了我想要使用的单元格 - 无论是F3,D2还是其他什么。
ActiveCell.Formula = "=BDP(F3&"" cusip"", ""security des"")"
有人可以帮忙吗?谢谢!
答案 0 :(得分:1)
You can make def ready():
print("Type the name of the excel file you wish to analyze.")
while True:
try:
a_input = input(">> ")
df = pd.read_excel("{}".format(a_input), parse_cols = "AS")
df2 = pd.read_excel("{}".format(a_input), parse_cols = "B")
df3 = pd.read_excel("{}".format(a_input), parse_cols = "A")
df4 = pd.read_excel("{}".format(a_input), parse_cols = "D")
df5 = pd.read_excel("{}".format(a_input), parse_cols = "C")
except IOError:
print("The file name was either entered incorrectly or is not in the directory")
else:
print("--------------------File Grab Successful--------------------")
break
time.sleep(2)
print("Grabbing the required data.....\n\n")
df.set_index('Last Date of Support', inplace=True)
df2.set_index('Product Series', inplace=True)
df3.set_index('Product Family', inplace=True)
df4.set_index('Item Name', inplace=True)
df5.set_index('Item Type', inplace=True)
time.sleep(2)
print("--------------Creating Excel Document with required data------------------\n\n")
time.sleep(2)
print("Type the name you want for the excel file that will be created. Be sure to add the file extension on the end (EX: filename.xlsx)")
b_input = input(">> ")
writer = pd.ExcelWriter('{}'.format(b_input), engine='xlsxwriter')
df.to_excel(writer, sheet_name='Sheet1', startrow=-1, startcol=0)
df2.to_excel(writer, sheet_name='Sheet1', startrow=-1, startcol=4)
df3.to_excel(writer, sheet_name='Sheet1', startrow=-1, startcol=2)
df4.to_excel(writer, sheet_name='Sheet1', startrow=-1, startcol=3)
df5.to_excel(writer, sheet_name='Sheet1', startrow=-1, startcol=1)
workbook = writer.book
worksheet = writer.sheets['Sheet1']
date = datetime.datetime.strptime('2018-01-01', "%Y-%m-%d")
format1 = workbook.add_format({'bg_color': '#FFC7CE',
'font_color': '#9C0006'})
worksheet.conditional_format('A2:A20000', {'type': 'date',
'criteria': 'less than',
'value': date,
'format': format1})
writer.save()
print("Goodbye!")
time.sleep(5)
ready()
variable dynamic if you like:
format1 = workbook.add_format({'bg_color': '#FFC7CE',
'font_color': '#9C0006'})
for i in df == format1:
print(i)
答案 1 :(得分:0)
If CName is the address of the cell you want to have the formula in, then try something like:
float:left
答案 2 :(得分:0)
谢谢大家的反馈和支持!我在休息一下并审核你的想法后想出来了!所以插入下面就可以了!我猜.address(,)是绝对必要的。
&安培; CName.Address(False,False)&
再次感谢!