讀取別表資料

2021-03-31 08:56:58 字數 980 閱讀 4786

讀取別表資料

officefans

幾種如何把別的工作表 sheet4 資料,讀到這個工作表的方法:在被讀取的單元格前加上工作表名稱 sheet4。

public sub writes()

1-- 2 方法,最簡單在被讀取的 "[ ]" 前加上被讀取的工作表名稱 sheet4。

1 [a1] = sheet4.[a1] '把sheet4 a1 單元格的資料,讀到 a1單元格。

2 [a2:a4] = sheet4.[b1] ''把 shee4 工作表單元格 b1 資料,讀到 a2:a4 單元格。

3-- 4 方法,在被讀取的工作表 range(" ")的 range 前加上被讀取的工作表名稱sheet4。

3 range("b1") = sheet4.range("b1") ''把 shee4工作表單元格 b1 資料,讀到 b1 單元格。

4 range("c1:c3") = sheet4.range("c1") '把 shee4 工作表單元格 c1 資料,讀到 c1:c3 單元格。

5-- 6 方法,在被讀取的工作表 cells(row,column),cells 前加上被讀取工作表名稱 sheet4。

5 cells(1, 4) = sheet4.cells(1, 4) '把 shee4 工作表單元格 d1 資料,讀到 d1 單元格。

6 range(cells(1, 5), cells(5, 5)) = sheet4.cells(1, 5) '把 shee4 工作表單元格 e1 資料,讀到 e1:e 5單元格。

end sub

你點選任何單元格,按 selection 按鈕,則所點選的單元格均會被輸入 shee4 工作表單元格 f1 資料。

public sub selection1()

selection.value = sheet4.[f1] '把 shee4 工作表單元格 f1 資料,讀到任何你點選的單元格。

end sub

附件: vbalesson2

讀取Excel表中資料

1 匯入python的excel包 pip install xlsx 2 在工程中建立一個 3 讀取excel表中資料,如下 import xlrd 這裡使用的excel檔案中資料為 文字 格式 開啟excel表 excel xlrd.open workbook 介面測試 data.xlsx 定位其...

讀取execl資料到表

將execl 內容讀取到 datatable 我這按照開始的列和結束的列並不是全部讀取 然後再將 datatable 中的內容對映到你的model中 也就是表中。execl 行名稱必須是和model對應 建議第一行中文註釋,第二行表欄位 從第二行開始讀取 將datatable 中的資料對映到mode...

c 讀取Excel表資料

1,使用oledb可以對excel檔案進行讀取.private dataset readexceltodataset string path 存放所有的sheet dataset set newdataset for int i 0 i sheetsname.rows.count i sheetna...

matlab對Excel表讀取資料

目錄 1.用xlsread函式讀取一個excel檔案 2.讀取指定sheet中的資料 2.讀取指定sheet中的資料 1 num xlsread filename filename是單引號括起來的帶路徑的檔名,函式直接讀取filename所指檔案的sheet1中的資料區域儲存到雙精度矩陣num中 其...

SQL SERVER 遊標迴圈讀取表資料

cursor 遊標 用於迴圈錶行資料,類似指標 格式如下 declare tempindex cursor for select from table 定義遊標 open tempindex 開啟遊標 fetch next from tempindex into x 抓取下一行資料給變數 while...