我需要有关 vba 代码的帮助以检查特定工作表中是否存在列,如果存在,则将列内容粘贴到另一张工作表,如果不存在,则在另一张工作表中打印 0
I searched and found this link https://www.excel-easy.com/vba/workbook-worksheet-object.html
You can refer to a member of the collection, for example, a single Worksheet object, in three ways.
- Using the worksheet name.
Worksheets("Sales").Range("A1").Value = "Hello"
- Using the index number (1 is the first worksheet starting from the left).
Worksheets(1).Range("A1").Value = "Hello"
- Using the CodeName.
Sheet1.Range("A1").Value = "Hello"
For counting empty columns I found https://docs.microsoft.com/en-us/office/vba/api/excel.worksheetfunction.counta
Example to check if column D is empty
IIf(WorksheetFunction.CountA(Columns("D")) = 0
To copy data I found https://analysistabs.com/excel-vba/copy-data-from-one-worksheet-to-another/
Try something and then update your question if you have doubts.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.