Thema Datum  Von Nutzer Rating
Antwort
18.04.2012 15:56:56 b-baller-juka
NotSolved
Blau Daten per schleife einlesen und wieder per schleife ausgeben!
18.04.2012 16:00:49 Gast26946
NotSolved
18.04.2012 19:01:48 Till
NotSolved
18.04.2012 19:04:02 Till
NotSolved
19.04.2012 14:20:48 Gast89230
NotSolved

Ansicht des Beitrags:
Von:
Gast26946
Datum:
18.04.2012 16:00:49
Views:
1090
Rating: Antwort:
  Ja
Thema:
Daten per schleife einlesen und wieder per schleife ausgeben!

so sieht der ganze code aus und irgendwie hakt es beim Auslesen...

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
Sub CommandButton1_Click()
     
    Initial
     
    'On Error Resume Next
     
    poDialog.Execute
     
End Sub
 
 
Sub CommandButton2_Click()
 
    '-------------check for playing around---------------
     
    Dim byWert As Byte
    byWert = MsgBox("If you want to create PO Number, push ok button!! Make sure that PO is completed!", vbOKCancel, "Confirmation")
    If byWert = 2 Then
        GoTo marke
    End If
     
    '-------------check for cost code and cost center---------------
 
    If Range("H13").Value = "" Or Range("H14").Value = "" Then
        MsgBox ("Please include Cost Code and Cost Center!")
         
        GoTo marke
    End If
     
    '==================================COPY DATA========================================
     
    Dim ponr, po_year
    Dim orderdate, po_nr, cost_acc, cost_cen, qt_nr, supplier1, c_attention1, c_tel1, c_fax1, c_email1
    Dim ship_to_customer, c_attention2, c_adress, o_name, o_tel, o_fax, o_email, counter, counter1
    Dim payment_terms, delivery_terms, delivery_time, total_price, curr, Items(20, 20), freight, taxed, nontaxed, tax
     
     
    Windows("PO_Tool_Optogan_Kopie.xlsm").Activate
    Sheets("PO Master").Select
    If Not Range("H7").Value = "" Then
            MsgBox ("This number already exists!")
        GoTo marke
    End If
     
    Sheets("PO Master").Select
     
    '-------------terms---------------
     
    orderdate = Range("H8").Value
    po_nr = Range("H7").Value
    cost_acc = Range("H13").Value
    cost_cen = Range("H14").Value
    qt_nr = Range("H9").Value
     
    '-------------contact person Optogan---------------
     
    o_name = Range("C41").Value
    'o_tel = Range("C42").Value
    'o_fax = Range("C43").Value
    o_email = Range("C44").Value
     
    '-------------supplier---------------
     
    supplier1 = Range("C7").Value
    c_adress = Range("C9").Value + ", " + Range("C10").Value + ", " + Range("C13").Value
    c_attention1 = Range("C8").Value
    c_tel1 = Range("C11").Value
    c_fax1 = Range("C12").Value
     
    '-------------conditions---------------
     
    payment_terms = Range("H12").Value
    delivery_terms = Range("H10").Value
    delivery_time = Range("H11").Value
    
    '-------------currency---------------
     
    curr = Range("G17").Value
    'curr = Right(curr, Len(curr) - 12)
    
    
    '-------------total price---------------
     
    total_price = Range("I251").Value
     
     
    '-------------copy items of sheet 1---------------
     
    Range("C18").Select
         
            For o = 0 To 9
             
                    Items(o, 0) = Range("C18").Offset(o, 0).Value
                     
                    Items(o, 1) = Range("D18").Offset(o, 0).Value
                     
                    Items(o, 2) = Range("E18").Offset(o, 0).Value
                     
                    Items(o, 3) = Range("F18").Offset(o, 0).Value
                     
                    Items(o, 4) = Range("G18").Offset(o, 0).Value
                     
                    Items(o, 5) = Range("H18").Offset(o, 0).Value
                     
                    Items(o, 6) = Range("I18").Offset(o, 0).Value
             
            For x = 0 To 9
             
                    Items(x, 0) = Range("C63").Offset(x, 0).Value
                     
                    Items(x, 1) = Range("D63").Offset(x, 0).Value
                     
                    Items(x, 2) = Range("E63").Offset(x, 0).Value
                     
                    Items(x, 3) = Range("F63").Offset(x, 0).Value
                     
                    Items(x, 4) = Range("G63").Offset(x, 0).Value
                     
                    Items(x, 5) = Range("H63").Offset(x, 0).Value
                     
                    Items(x, 6) = Range("I63").Offset(x, 0).Value
            Next
            Next
 
             
 
     
    '-------------check if file is open---------------
     
    If IsFileOpen("O:\PO\2_PO_MI\PO#.xls") Then
         
        MsgBox "Somebody is using the PO# file. Please check in Folder O:\PO\O:\PO\2_PO_MI\PO#.xls or try later!"
        GoTo marke
    End If
 
    If IsFileOpen("O:\PO\PO_Database.xlsx") Then
         
        MsgBox "Somebody is using the PO_Database file. Please check in Folder O:\PO\PO_Database.xlsx or try later!"
        GoTo marke
    End If
     
    Workbooks.Open Filename:="O:\PO\2_PO_MI\PO#.xls"
    Sheets("2011").Select
     
    Range("a10").Select
     
    Dim currentmonth, nextponr
     
    currentmonth = Right(Date, 7)
    currentmonth = Right(currentmonth, 4) & "_" & Left(currentmonth, 2)
    
     
    While Not currentmonth = Left(Selection.Value, 7) 'red
        Selection.Offset(0, 1).Select
              
    Wend
 
    While Selection.Interior.Color = 255  'red
             
        Selection.Offset(1, 0).Select
     
    Wend
    Selection.Interior.Color = 255
    nextponr = Selection.Value
    ActiveWorkbook.Close SaveChanges:=True
     
     
     
    '=========================================CREATE PO NR========================================
 
    '-------------check if file is open---------------
     
    If IsFileOpen("O:\PO\PO_Database.xlsx") Then
         
        MsgBox "Somebody is using the PO_Database file. Please check in Folder O:\PO\PO_Database.xlsx or try later!"
        GoTo marke
    End If
     
    Workbooks.Open Filename:="O:\PO\PO_Database.xlsx"
    Sheets("PO database").Select
     
    Range("A7").Select
     
    Dim pocheck, pobasic
    
    While Not IsEmpty(Selection.Value)
        Selection.Offset(1, 0).Select
    Wend
    
    ponr = Selection.Offset(-1, 0).Value
    pocheck = Left(ponr, 7)
    ponr = Right(ponr, Len(ponr) - 8)
    ponr = ponr + 1
    pobasic = Right(Date, 7)
    pobasic = Right(pobasic, 4) & "_" & Left(pobasic, 2)
     
    '-------------beginning of new month---------------
     
    If Not pobasic = pocheck Then
        ponr = 1
    End If
         
    ponr = pobasic & "_" & ponr
     
     
    If Not ponr = nextponr Then
        MsgBox ("there is discrepance between new and old po system!")
        ponr = nextponr
    End If
     
    '=========================================STORE DATA FROM DASHBOARD========================================
     
    Windows("PO_Tool_Optogan_Kopie.xlsm").Activate
    Sheets("PO Master").Select
         
    Range("H7").Value = ponr
    
    Windows("PO_Database.xlsx").Activate
    Sheets("po database").Select
    Selection.Value = ponr
     
    '-------------1_order date---------------
     
    Selection.Offset(0, 1).Value = orderdate
     
    '-------------2_quotation number---------------
     
    Selection.Offset(0, 2).Value = qt_nr
    
    '-------------3_cost code---------------
     
    Selection.Offset(0, 3).Value = cost_acc
     
    '-------------4_cost center---------------
     
    Selection.Offset(0, 4).Value = cost_cen
     
    '-------------5_supplier---------------
     
    Selection.Offset(0, 5).Value = supplier1
    
    '-------------6_customer adress---------------
     
    Selection.Offset(0, 6).Value = c_adress
    
    '-------------7_customer attention---------------
     
    Selection.Offset(0, 7).Value = c_attention1
     
    '-------------8_customer tel---------------
     
    Selection.Offset(0, 8).Value = c_tel1
     
    '-------------9_customer fax---------------
 
    Selection.Offset(0, 9).Value = c_fax1
  
    '-------------10_OG name---------------
     
    Selection.Offset(0, 10).Value = o_name
     
    '-------------11_OG email---------------
     
    Selection.Offset(0, 11).Value = o_email
     
    '-------------12_payment terms---------------
     
    Selection.Offset(0, 12).Value = payment_terms
     
    '-------------13_delivery terms---------------
     
    Selection.Offset(0, 13).Value = delivery_terms
     
    '-------------14_delivery time---------------
     
    Selection.Offset(0, 14).Value = delivery_time
     
    '-------------15_total price---------------
     
    Selection.Offset(0, 15).Value = total_price
     
    '-------------16_currency---------------
    
    Selection.Offset(0, 16).Value = curr
     
 
      
    '=========================================STORE PRODUCTS OF DASHBOARD========================================
    
    '-------------1_sheet---------------
     
         counter = 0
         
            For o = 0 To 9
                For i = 0 To 6
                    counter = counter + 1
                    Selection.Offset(0, 17 + counter).Value = Items(o, i)
                Next
                 
            For x = 0 To 9
                For u = 0 To 6
                counter = counter + 1
                Selection.Offset(0, 87 + counter).Value = Items(x, u)
                Next
                 
            Next
            Next
              
             
    '-------------save and close---------------
    
    ActiveWorkbook.Close SaveChanges:=True
    Windows("PO_Tool_Optogan_Kopie.xlsm").Activate
    Sheets("po master").Select
marke:
 
End Sub
 
Sub DruckenSpeichern()
     
    Dim poname
     
    Sheets("PO Master").Select
    poname = Range("L3").Value & "_" & Range("C35").Value
    If Range("L3").Value = "" Then
        MsgBox ("Please, create po number!")
        GoTo marke
    End If
     
 
    '-------------save file---------------
    ActiveWorkbook.SaveAs Filename:= _
        "O:\PO\3_POP\" + poname + ".xls", FileFormat:=xlOpenXMLWorkbook _
        , CreateBackup:=False
    ActiveWorkbook.Close
         
marke:
     
     
End Sub
 
 
Public Function IsFileOpen(ByRef Path As String) As Boolean
  Dim FileNr As Integer
  Dim ErrorNr As Long
 
'Datei testweise öffnen:
  On Error Resume Next
    FileNr = FreeFile
    Open Path For Input Lock Write As #FileNr
      ErrorNr = Err.Number
    Close #FileNr
  On Error GoTo 0
 
  'Ggf. Fehler verarbeiten:
  Select Case ErrorNr
  Case 0    'kein Fehler:
    'NOP
  Case 70   'Permission denied':
    IsFileOpen = True
  Case Else 'sonstiger Fehler:
    Err.Raise ErrorNr
  End Select
End Function
 

 


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
18.04.2012 15:56:56 b-baller-juka
NotSolved
Blau Daten per schleife einlesen und wieder per schleife ausgeben!
18.04.2012 16:00:49 Gast26946
NotSolved
18.04.2012 19:01:48 Till
NotSolved
18.04.2012 19:04:02 Till
NotSolved
19.04.2012 14:20:48 Gast89230
NotSolved