LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Exporting a Varying Row to a CSV file.

Hi Everyone,

I (as you will soon discover) am extremly new to VBA and I desperatly
need some advice. I am currenty writing (in EXCEL) a User interface to
create a work order with work order details (Product 1, 2, 3, Etc.). I
then need to send the varying range of cells to a CSV file. Because
the number of products will Vary, the number of columns will vary.
This will create a Variance in the Range. Any suggestions on how to
capture this? (I am Including my code for the frmOrdDetail)

Any help would be appreciated,

Thanks,
Gary

' Declare my Variables

Dim ColNum As Integer
Dim Row As Integer
Dim flgNext As Boolean

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdSubmit_Click()

' Make sure sheet1 is active
Sheets("Orders").Activate

NextRow = _
Application.WorksheetFunction.CountA(Range("A:A"))

'Flag Next?
If flgNext Then
ColNum = ColNum + 3
Else
ColNum = 16
End If

' Make sure that all needed fields are completed

' Product Number
If txtProdNum.Text = "" Then
MsgBox "You must enter a Product Number"
txtProdNum.SetFocus
Exit Sub
End If

' Description
If txtProdDesc.Text = "" Then
MsgBox "You must enter a Description!"
txtProdDesc.SetFocus
Exit Sub
End If

' Quantity
If txtQty.Text = "" Then
MsgBox "You must enter a Quantity!"
txtQty.SetFocus
Exit Sub
End If

' Transfer the Product Number
Cells(NextRow, ColNum) = txtProdNum.Text

' Transfer the Product Description
Cells(NextRow, ColNum + 1) = txtProdDesc.Text

' Transfer Qty
Cells(NextRow, (ColNum + 2)) = txtQty.Text

NextLine = MsgBox("Would you like to enter another Product?",
vbYesNo)
If NextLine = vbYes Then
txtProdNum.Text = ""
txtProdDesc.Text = ""
txtQty.Text = ""

txtProdNum.SetFocus
flgNext = True
Else
cmdSubmit.Visible = False
cmdTransfer.Visible = True
flgNext = False
End If

End Sub


Private Sub cmdTransfer_Click()
' This is Where I am StucK
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting to CSV file Paul Bytes Excel Discussion (Misc queries) 1 January 3rd 07 04:21 PM
Exporting a PDF file monkster Excel Discussion (Misc queries) 0 May 2nd 06 08:18 PM
Exporting to csv file Geri Excel Discussion (Misc queries) 5 September 6th 05 02:48 PM
File opening via Macro with varying file name TomFish79 Excel Programming 3 August 15th 05 02:32 PM
Exporting CSV file to unicode .txt file - " around strings Paul Excel Discussion (Misc queries) 1 June 14th 05 12:27 AM


All times are GMT +1. The time now is 07:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"