所以我有下表:
我正在尝试应用此代码:
Public Sub reformatData()
Dim line As Double, colData As Double, rowData As Double, counter As Double
Dim newWs As Worksheet, baseWs As Worksheet
Dim tWb As Workbook
Set tWb = ThisWorkbook
Set newWs = tWb.Worksheets("New Table")
Set baseWs = tWb.Worksheets("RAW DATA")
line = 1
While baseWs.Cells(counter, 1) <> “”
newWs.Cells(line, 1) = baseWs.Cells(counter, 1)
newWs.Cells(line, 2) = baseWs.Cells(counter, 2)
newWs.Cells(line, 3) = "Product 1"
newWs.Cells(line, 4) = baseWs.Cells(counter, 3)
line = line + 1
newWs.Cells(line, 1) = baseWs.Cells(counter, 1)
newWs.Cells(line, 2) = baseWs.Cells(counter, 2)
newWs.Cells(line, 3) = "Product 2"
newWs.Cells(line, 4) = baseWs.Cells(counter, 4)
line = line + 1
counter = counter + 1
Wend
End Sub
当我尝试调试时,此行出现错误1004:
While baseWs.Cells(counter, 1) <> “”
我在一次采访中得到了这个,所以我试图弄清楚代码是如何工作的,但是我什至无法应用!
感谢所有帮助,TIA。