Hi All
I am using the follwoing code:
Sub exportRangeToFishBowlPO()
Dim myCSVFileName As String
Dim myWB As Workbook
Dim rngToSave As Range
Dim fNum As Integer
Dim csvVal As String
Set myWB = ThisWorkbook
myCSVFileName = "C:\PurchaseOrder.csv"
csvVal = ""
fNum = FreeFile
Set rngToSave = Range("A1:C50")
Open myCSVFileName For Output As #fNum
For i = 1 To rngToSave.Rows.Count
For j = 1 To rngToSave.Columns.Count
csvVal = csvVal & Chr(34) & rngToSave(i, j).Value & Chr(34) & ","
Next
Print #fNum, Left(csvVal, Len(csvVal) - 2)
csvVal = ""
Next
Close #fileNumber
End Sub
For the highlighted code Set rngToSave = Range("A1:C50") I would like to pass a range reference to the VBA function as the range can change depending on the length of the purchase order. So I created an named range called "PORange". My question is how do I replace = Range("A1:C50") with the cell references contained in the Named Range "PORange"?
Many Thanks
Jack
I am using the follwoing code:
Sub exportRangeToFishBowlPO()
Dim myCSVFileName As String
Dim myWB As Workbook
Dim rngToSave As Range
Dim fNum As Integer
Dim csvVal As String
Set myWB = ThisWorkbook
myCSVFileName = "C:\PurchaseOrder.csv"
csvVal = ""
fNum = FreeFile
Set rngToSave = Range("A1:C50")
Open myCSVFileName For Output As #fNum
For i = 1 To rngToSave.Rows.Count
For j = 1 To rngToSave.Columns.Count
csvVal = csvVal & Chr(34) & rngToSave(i, j).Value & Chr(34) & ","
Next
Print #fNum, Left(csvVal, Len(csvVal) - 2)
csvVal = ""
Next
Close #fileNumber
End Sub
For the highlighted code Set rngToSave = Range("A1:C50") I would like to pass a range reference to the VBA function as the range can change depending on the length of the purchase order. So I created an named range called "PORange". My question is how do I replace = Range("A1:C50") with the cell references contained in the Named Range "PORange"?
Many Thanks
Jack