Hi
I have the following code which works by copying a range of cells from one worksheet and pastes them into another. However, I now need to change one of the cell values from the range by adding an apostrophy ( ' ) in front of it so that if the cell value was 452 it becomes '452
This change need to be applied to values in (iRow, "Q") where the value of i can be from 20 to 35. I tried adding a line like
set value (iRow,"Q")= "'" & (iRow,"Q") but I get an error.
Can anyone help solve this for me?
Thanks.
Talât
I have the following code which works by copying a range of cells from one worksheet and pastes them into another. However, I now need to change one of the cell values from the range by adding an apostrophy ( ' ) in front of it so that if the cell value was 452 it becomes '452
Code:
Sub InvoiceToBatch()
'Copies the current invoice in the INVOICE TEMPLATE sheet of
'this workbook to stocksbatch.xls
Dim myRange As String
Dim Account As String
Dim InvDate As Date
Dim InvNum As Long
Dim InvSheet As Worksheet
Dim BatchSheet As Worksheet
Dim NextRow As Long 'the next available invoice row on the batch sheet
Dim oRow As Long 'row number on BatchSheet
Dim iRow As Long 'row number on InvSheet
Set InvSheet = ThisWorkbook.Worksheets("INVOICE TEMPLATE")
Workbooks.Open Filename:="G:\PUBS\PP-MS\INVOICES\stocksbatch.xls"
Set BatchSheet = ActiveWorkbook.Worksheets("Sheet1")
oRow = BatchSheet.UsedRange.Rows.Count + 1
iRow = 20
Do
myRange = InvSheet.Range(InvSheet.Cells(iRow, "B"), InvSheet.Cells(iRow, "K")).Address & _
"," & InvSheet.Cells(iRow, "Q").Address
InvSheet.Range(myRange).Copy
BatchSheet.Cells(oRow, "D").PasteSpecial xlPasteValues
InvSheet.Range("E5").Copy 'Account
BatchSheet.Cells(oRow, "A").PasteSpecial xlPasteValues
InvSheet.Range("K2").Copy 'InvNum
BatchSheet.Cells(oRow, "B").PasteSpecial xlPasteValues
InvSheet.Range("F17").Copy 'InvDate
BatchSheet.Cells(oRow, "C").PasteSpecial xlPasteValues
iRow = iRow + 1
oRow = oRow + 1
Loop Until IsEmpty(InvSheet.Cells(iRow, "B")) Or InvSheet.Cells(iRow, "B") = Q
Application.CutCopyMode = False
ActiveWorkbook.Close True 'save changes and close
Application.Run "FAPBatchFile"
End Sub
This change need to be applied to values in (iRow, "Q") where the value of i can be from 20 to 35. I tried adding a line like
set value (iRow,"Q")= "'" & (iRow,"Q") but I get an error.
Can anyone help solve this for me?
Thanks.
Talât