我已经搜索过这个问题,但所有的例子都太复杂了。 我只是不能使用“设置工作簿”和“设置工作表”对象。我将得到错误1004:对象定义的错误。
我想从目标文件表“路径”中读取路径:C:\ Users \ Holger \ Documents \ VBA \ WB_data.xlsx
请有人帮忙。
Sub Get_numbers()
'I have got 2 sheets
Dim WB_dest As Workbook
Dim WB_data As Workbook
'I need 3 worksheets
Dim path_sheet As Worksheet
Dim dest_sheet As Worksheet
Dim data_sheet As Worksheet
'Data worksheet's path
Dim path As String
'Counter
Dim i As Byte
'I run this sub from destination file sheet "PATH" which is already open
Set WB_dest = ThisWorkbook
Set path_sheet = WB_dest.Worksheets("Path")
Set dest_sheet = WB_dest.Worksheets("TO")
'I set worksheet from the Excel taht I do not need to open, just reading
Set WB_data = Workbooks.Open(path)
Set data_sheet = WB_data.Worksheets("FROM")
'Data sheet contains three numbers in the first column
'and destination sheet also contains only three numbers in the first coulm
'I would like to add data_sheet numbers after dest_sheet numbers
For i = 4 To 6
dest_sheet.Cells(i, 1) = data_sheet(i, 1)
Next i
答案 0 :(得分:0)
试试这个......
import requests, bs4
import numpy as np
import requests
import pandas as pd
res = requests.get('http://www.ebay.com/sch/i.html? LH_Complete=1&LH_Sold=1&_from=R40&_sacat=0&_nkw=gerald%20ford%20autograph&r t=nc&LH_Auction=1&_trksid=p2045573.m1684')
res.raise_for_status()
soup=bs4.BeautifulSoup(res.text, "lxml")
# grabs the link, selling price, and # of bids from historical auctions
df = pd.DataFrame()
l = []
p = []
b = []
for links in soup.find_all(class_="vip"):
l.append(links)
for bids in soup.find_all("li", "lvformat"):
b.append(bids)
for prices in soup.find_all("span", "bold bidsold"):
p.append(prices)
x = np.array((l,b,p))
z = x.transpose()
df = pd.DataFrame(z)
df.to_csv('/Users/toasteez/ebay.csv')