我在工作表中有几张名为1,2,3,4,5,6,7 ......
我需要复制1张单页中的所有文件。
我现在找不到只有一个"给表格命名。
问题出现在这里:
varNBLIGNES = Sheets(""" & varDC & """).Range(COLNUM & ":" & COLNUM).Cells.SpecialCells(xlCellTypeConstants).Count
'CONSTANTS
Const COLNUM As String = "B" 'PART NUMBERS WILL ALWAYS BE IN THE B COLUM FOR EVERY EXCEL FILES
Const COLPRC As String = "C" 'NEW LIST PRICE WILL ALWAYS BE IN THE C COLUM FOR EVERY EXCEL FILES
Const COLDSC As String = "Q" 'NEW DESCRIPTION WILL ALWAYS BE IN THE Q COLUM FOR EVERY EXCEL FILES
Const COLUOM As String = "S" 'NEW UNIT OF MESURE WILL ALWAYS BE IN THE S COLUM FOR EVERY EXCEL FILES
Const COLUIP As String = "T" 'NEW UNIT IN PACKAGE WILL ALWAYS BE IN THE T COLUM FOR EVERY EXCEL FILES
Const vbDoubleQuote As String = """"
'VARIABLES
Dim varNBLIGNES As Integer
Dim varDC As Integer
Dim varDCS As String
Dim i As Integer
Dim quote As String
'INITIALIZATION
varNBLIGNES = 0
varDC = Sheets(2).Range("P5").Value
varDCS = ""
i = 1
quote = Chr(34)
'SUB CODE TO COMPILE FILES INTO ONE
'While varDC >= i
varNBLIGNES = Sheets(""" & varDC & """).Range(COLNUM & ":" & COLNUM).Cells.SpecialCells(xlCellTypeConstants).Count
varNBLIGNES = varNBLIGNES + 1
Sheets(varDC).Range("B3:" & COLNUM & varNBLIGNES).Copy
Sheets(4).Select
Range("B4").Select
ActiveSheet.Paste
'Sheets("PROD FOUR").Select
'Range("B4").Select
'ActiveSheet.Paste
'varDC = varDC - 1
'Wend
正如你所看到的,我试图在CONST中声明它,我也试图创建" CHR(34)"并且一切都会失败。
我做错了什么?提前谢谢你
答案 0 :(得分:-1)
要在字符串中添加引号,请使用不同类型的引号,例如
"'" & varDC & "'"