Please help,
I am stuck trying to code to put a formula into a column of cells, the formula has enbeded quotes which seem to stop the line from running.
Cells(iRow, 2).Value = "=MID(G11,FindN(""" \ """,G11,$C$8),(CntPosLCh(G11,""" \ """)-FindN(""" \ """,G11,$C$8)+1))"
I have tried the double quotes but that doesn't work.
If I replace the formula with "test" the cells fill fine, so the first part of this line is ok. It's the quotes inside the formula that is the problem
and I have to have the quotes in the formula.
here is the Sub code the line is in;
Sub ListMyFiles(mySourcePath, IncludeSubfolders)
Set MyObject = New Scripting.FileSystemObject
Set mySource = MyObject.GetFolder(mySourcePath)
On Error Resume Next
For Each myFile In mySource.Files
iCol = 7
Cells(iRow, iCol).Value = myFile.Path
iCol = iCol - 3
Cells(iRow, iCol).Value = myFile.Name
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.Size
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.DateLastModified
Cells(iRow, 2).Value = "=MID(G11,FindN(""" \ """,G11,$C$8),(CntPosLCh(G11,""" \ """)-FindN(""" \ """,G11,$C$8)+1))"
iRow = iRow + 1
Next
If IncludeSubfolders Then
For Each mySubFolder In mySource.SubFolders
Call ListMyFiles(mySubFolder.Path, True)
Next
End If
End Sub
any help or suggestions are appreciated.
I am stuck trying to code to put a formula into a column of cells, the formula has enbeded quotes which seem to stop the line from running.
Cells(iRow, 2).Value = "=MID(G11,FindN(""" \ """,G11,$C$8),(CntPosLCh(G11,""" \ """)-FindN(""" \ """,G11,$C$8)+1))"
I have tried the double quotes but that doesn't work.
If I replace the formula with "test" the cells fill fine, so the first part of this line is ok. It's the quotes inside the formula that is the problem
and I have to have the quotes in the formula.
here is the Sub code the line is in;
Sub ListMyFiles(mySourcePath, IncludeSubfolders)
Set MyObject = New Scripting.FileSystemObject
Set mySource = MyObject.GetFolder(mySourcePath)
On Error Resume Next
For Each myFile In mySource.Files
iCol = 7
Cells(iRow, iCol).Value = myFile.Path
iCol = iCol - 3
Cells(iRow, iCol).Value = myFile.Name
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.Size
iCol = iCol + 1
Cells(iRow, iCol).Value = myFile.DateLastModified
Cells(iRow, 2).Value = "=MID(G11,FindN(""" \ """,G11,$C$8),(CntPosLCh(G11,""" \ """)-FindN(""" \ """,G11,$C$8)+1))"
iRow = iRow + 1
Next
If IncludeSubfolders Then
For Each mySubFolder In mySource.SubFolders
Call ListMyFiles(mySubFolder.Path, True)
Next
End If
End Sub
any help or suggestions are appreciated.