View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
James James is offline
external usenet poster
 
Posts: 542
Default VBA Help...I need a lot

The data comes to me in one workbook with multiple sheets. I have a template
that is specified for my oracle uploading. I would like to see the data come
from the provided data into my template. My template is set-up so that each
sample has its own row. I do not think a transpose will work for this.
Below you will find the code I have. This code is only for locating where
the data is coming from, I do not know how to attack the importing part of
the macro.

Sub Humble_DataImport()
On Error GoTo err_ImportData

Const lngLast As Long = 65536
Dim lngLastRow As Long
Dim i As Long
Dim r As Long
Dim j As Integer
Dim strDataFileName As String
Dim strInitFileName As String
Dim strInitShtName As String
Dim intStartRow As Integer
Dim strLookupShtName As String
Dim bFlag As Boolean
Dim k As Integer
Dim m As Integer
Dim intFirstInputRow As Integer
Dim intLastInputCol As Integer
Application.ScreenUpdating = False

strInitFileName = ActiveWorkbook.Name
strInitShtName = ActiveSheet.Name
intStartRow = 9 'beginning row on lookup sht
intFirstInputRow = 3 'first row on template sheet
intLastInputCol = 27 'last column we're importing on template sheet,
currently T (20)
r = intFirstInputRow
k = 1
m = 1

lngLastRow = Cells(lngLast, 1).End(xlUp).Row
If lngLastRow intFirstInputRow - 1 Then
Range(Cells(intFirstInputRow, 1).Address & ":" & Cells(lngLastRow,
intLastInputCol).Address).Clear
End If

'obtain and open data file
strDataFileName = Application.GetOpenFilename("Microsoft Excel (*.xls),
*.xls")
bFlag = True
If strDataFileName = False Then
If k < 2 Then
MsgBox "No file was selected. This procedure will now be
terminated."
GoTo exit_ImportData
End If
End If
If strDataFileName = "" Or Len(strDataFileName) = 0 Then
MsgBox "No file was selected. This procedure will now be
terminated."
GoTo exit_ImportData
End If
bFlag = False

'check to see if file already open
For i = 1 To Workbooks.Count
If Workbooks(i).FullName = strDataFileName Then
Workbooks(i).Activate
strDataFileName = Workbooks(i).Name
m = 2
Exit For
End If
Next i

'don't reopen
If m = 1 Then
Workbooks.Open Filename:=strDataFileName
strDataFileName = ActiveWorkbook.Name
End If
ActiveWorkbook.Sheets("report").Activate
strLookupShtName = ActiveSheet.Name
lngLastRow = Cells(lngLast, 1).End(xlUp).Row

'cycle thru rows and input data
For i = intStartRow To lngLastRow
If Len(Workbooks(strDataFileName).Sheets(strLookupSht Name).Cells(i,
2).Value) 0 Then




"dan dungan" wrote:

I'm not clear what type of macro you are trying to create.

Do you want to transpose the data from rows to columns?

Is the template spreadsheet the file specification for the file to
import into Oracle?

Please show the code for your macro.