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: 1
Default Getting a weird result on this one sheet in Excel

I am trying to extract data from several Excel spreadsheets using the
Excel object in VBA (Access 2000, specifically). However, this one
spreadsheet is giving me a headache.

This is the code:

Sub ProcessSpreadsheet(xlbk As Excel.Workbook)
Dim xlsheet As Excel.Worksheet
Dim RSOUT As Recordset
Dim style As String
Dim color As String
Dim ONHAND As Long
Dim i As Long
Set RSOUT = CurrentDb.OpenRecordset("tblCutOrders")
RSOUT.Index = "PrimaryKey"
For Each xlsheet In xlbk.Worksheets
With xlsheet
'If xlsheet.Name = "VEGAS GOLD" And .Range("G1") = "95" Then
Stop
ONHAND = 0
If .Name < "TOTAL" Then
color = .Name
style = .Range("G1")
i = 4
Do Until xlsheet.Range("D" & i) = "TOTAL"
If InStr(1, .Range("D" & i), "INVENTORY") 0 Or
InStr(1, .Range("D" & i), "ADJUST") 0 Or Trim(.Range("D" & i)) = ""
Or InStr(1, .Range("D" & i), "RECEIVED") 0 Or InStr(1, .Range("D" &
i), "DEFECT") 0 Then
Debug.Print "Not a cut"
ONHAND = ONHAND + Val(xlsheet.Range("e" & i))
ElseIf InStr(1, xlsheet.Range("D" & i), "ORDER") 0
Then
CurrentDb.Execute "INSERT INTO
tblFabricOrders(STYLE,COLOR,FabricOrder,Yards) VALUES('" & style &
"','" & color & "','" & .Range("D" & i) & "'," & .Range("E" & i) & ")"
ONHAND = ONHAND
Else
RSOUT.Seek "=", style, color, xlsheet.Range("D" &
i)
If Not RSOUT.NoMatch Then
RSOUT.Edit
RSOUT!CUTYARDS = -1 * Val(xlsheet.Range("E"
& i))
RSOUT.Update
Else
RSOUT.AddNew
RSOUT!style = style
RSOUT!color = color
RSOUT!CUTORDERNUMBER = xlsheet.Range("D" &
i)
RSOUT!CUTYARDS = -1 * Val(xlsheet.Range("E"
& i))
RSOUT.Update
End If
ONHAND = ONHAND + Val(xlsheet.Range("e" & i))
End If
i = i + 1
DoEvents
Loop
CurrentDb.Execute "INSERT INTO tblInventory(STYLE, COLOR,
Yards) VALUES('" & style & "','" & color & "'," & ONHAND & ")"
End If
End With
Next

End Sub


I call ProcessSpreadsheet with xlbk defined as an Excel Workbook. When
I get to the part where it looks for values in xlsheet.range("E" & i)
or .range("E" & i) (I've tried it both ways), the value for
..range("E4") is blank on this one sheet, but when I go to the sheet,
cell E4 is certainly not blank and has a numeric value in it.

I've recreated the sheet, cut and pasted values into it, to no avail.
Other sheets seem to work just fine, according to the person who was
looking at the data with me.

 
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
2 level subtotal result weird HFLo Excel Discussion (Misc queries) 2 November 30th 09 06:29 PM
Weird Problem while Importing Data into another sheet Sundar Excel Discussion (Misc queries) 0 July 2nd 08 04:50 PM
Result from many excel file sheet Akader Excel Programming 10 May 4th 06 07:07 AM
Weird result Roger B. Excel Programming 2 August 9th 05 04:55 AM
Array formula weird result Solerman Kaplon via OfficeKB.com Excel Discussion (Misc queries) 2 December 21st 04 08:39 PM


All times are GMT +1. The time now is 07:01 AM.

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"