Arkadaşlar lütfen yardım edin.
Aşağıda kırmızıya boyadığım satırda "Subscript out of range" hatası alıyorum ve bir türlü çözemiyorum.
İlginç olan bu kodlar bir bilgisayarda düzgün çalışıyor fakat diğer bilgisayarlarda bu hatayı vererek çalışmıyor.
Bu hata ile ilgili temel mevzuyu biliyorum. Yani dizi yada koleksiyonun olmayan bir üyesine başvuru yapmak gibi bir durum söz konusu değil.
internettede epey araştırma yaptım bulamadım.
BOYAMA LİSTESİ isimli excel dosyası açık iken sanki böyle bir dosya yokmuş gibi hata vermesinin sebebi ne olabilir.
Kafayı yiyeceğim.Çaresiz kaldım
Ustalardan yardım istiyorum.
Aşağıda kırmızıya boyadığım satırda "Subscript out of range" hatası alıyorum ve bir türlü çözemiyorum.
İlginç olan bu kodlar bir bilgisayarda düzgün çalışıyor fakat diğer bilgisayarlarda bu hatayı vererek çalışmıyor.
Bu hata ile ilgili temel mevzuyu biliyorum. Yani dizi yada koleksiyonun olmayan bir üyesine başvuru yapmak gibi bir durum söz konusu değil.
internettede epey araştırma yaptım bulamadım.
BOYAMA LİSTESİ isimli excel dosyası açık iken sanki böyle bir dosya yokmuş gibi hata vermesinin sebebi ne olabilir.
Kafayı yiyeceğim.Çaresiz kaldım
Ustalardan yardım istiyorum.
Kod:
Sub kirmizi()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Dim c As Boolean
If Selection.Cells.Count = 1 Then
Dim s As String, t As String, y As String
s = ActiveCell.Row
t = ActiveCell.Column
[B] [COLOR="Red"] If Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), (CInt(t))).Value > _
Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), 17).Value Then[/COLOR][/B]
b = MsgBox("sipariş kalan miktarı aştı eminmisiniz", vbYesNo)
If b = vbYes Then
c = True
GoTo label0
Else
ActiveCell.Value = 0
Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), 18).Value = 0
GoTo label1
End If
End If
label0:
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), (CInt(t) + 1)).Value = Date
Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), 18).Value = ActiveCell.Value
Dim path As String, depo As String, ihaleadi As String, sayfadi As String, bugun As String
bugun = DateTime.Date
'path = "D:\BOYAMA\SİPARİŞ\" & CStr(DateTime.Date) & ".xlsx"
path = "D:\BOYAMA\SİPARİŞ\" & CStr(DateTime.Date) & ".xlsx"
depo = CStr(Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 4).Value)
ihaleadi = Mid(CStr(Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 2).Value), 6, 10)
If c Then
sayfadi = depo + "-" + ihaleadi + "++%20"
Else
sayfadi = depo + "-" + ihaleadi
End If
If Dir(path) = "" Then
Workbooks("BOYAMA LİSTESİ").Worksheets("SF").copy
ActiveWorkbook.SaveAs path
ActiveWorkbook.Worksheets("SF").Name = sayfadi
For i = 19 To 47 Step 2
If Workbooks(bugun).Worksheets(sayfadi).Cells(i, 1).Value = "" Then 'eğer dosyada bugün tarihli bir sipariş yoksa
With Workbooks(bugun).Worksheets(sayfadi)
.Cells(i, 1).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 3).Value
.Cells(i, 4).Value = depo
.Cells(i, 5).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 6).Value
.Cells(i, 6).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 8).Value
.Cells(i, 10).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), 18).Value
.Cells(6, 2).Value = depo
.Cells(12, 8).Value = bugun
If c Then
.Cells(13, 2).Value = "%20 İŞ ARTIŞI"
End If
End With
With ActiveSheet.Range("a" + CStr(i - 2) + ":" + "j" + CStr(i + 1))
.Borders.LineStyle = xlNone
.Borders.LineStyle = xlContinuous
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlEdgeLeft).TintAndShade = 0
.Borders(xlEdgeTop).TintAndShade = 0
.Borders(xlEdgeBottom).TintAndShade = 0
.Borders(xlEdgeRight).TintAndShade = 0
.Borders(xlEdgeLeft).ColorIndex = 0
.Borders(xlEdgeTop).ColorIndex = 0
.Borders(xlEdgeBottom).ColorIndex = 0
.Borders(xlEdgeRight).ColorIndex = 0
End With
Exit For
Else
End If
Next i
Workbooks(bugun).Save
Else 'eğer bugün tarihli bir sipariş exceli varsa
Dim kitap As Workbook
Dim acıkmı As Boolean
For Each kitap In Workbooks
If kitap.Name = bugun + ".xlsx" Then
acıkmı = True
Else
End If
Next
If acıkmı = False Then
Workbooks.Open Filename:=path
End If
Dim varmi As Boolean
For i = 1 To Workbooks(bugun).Sheets.Count
If Workbooks(bugun).Sheets(i).Name = sayfadi Then
varmi = True
Exit For
Else
' varmi = False
End If
Next i
If varmi Then 'eğer bugün tarih tarihli bir excelde bu depo+ihale adlı sipariş varsa
Dim var1 As Boolean, var2 As Boolean
Dim m As Integer
For n = 19 To 47 Step 2
With Workbooks(bugun).Worksheets(sayfadi)
If .Cells(n, 1).Value = "" Then
Exit For
Else
If .Cells(n, 5).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 6).Value _
And .Cells(n, 10).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 18).Value Then
var1 = True
ElseIf .Cells(n, 5).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 6).Value _
And .Cells(n, 10).Value <> Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 18).Value Then
var2 = True
m = n
Else
End If
End If
End With
Next n
If var1 Then
MsgBox ("bu siparişten var")
GoTo label3
ElseIf var2 Then
Workbooks(bugun).Worksheets(sayfadi).Cells(m, 10).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 18).Value
MsgBox ("sipariş miktarı başarı ile güncellendi")
Else
For i = 19 To 47 Step 2
If Workbooks(bugun).Worksheets(sayfadi).Cells(i, 1).Value = "" Then
With Workbooks(bugun).Worksheets(sayfadi)
.Cells(i, 1).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 3).Value
.Cells(i, 4).Value = depo
.Cells(i, 5).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 6).Value
.Cells(i, 6).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 8).Value
.Cells(i, 10).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), 18).Value
End With
With Workbooks(bugun).Worksheets(sayfadi).Range("a" + CStr(i - 2) + ":" + "j" + CStr(i + 1))
.Borders.LineStyle = xlNone
.Borders.LineStyle = xlContinuous
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlEdgeLeft).TintAndShade = 0
.Borders(xlEdgeTop).TintAndShade = 0
.Borders(xlEdgeBottom).TintAndShade = 0
.Borders(xlEdgeRight).TintAndShade = 0
.Borders(xlEdgeLeft).ColorIndex = 0
.Borders(xlEdgeTop).ColorIndex = 0
.Borders(xlEdgeBottom).ColorIndex = 0
.Borders(xlEdgeRight).ColorIndex = 0
End With
Exit For
Else
End If
Next i
Workbooks(bugun).Save
End If
Else 'eğer bugün tarih tarihli bir excelde bu depo+ihale adlı sipariş yoksa
Dim syf As Worksheet
Dim say As Integer
Dim varm2 As Boolean
Dim depo1 As String
For Each syf In Workbooks(bugun).Worksheets
say = InStr(syf.Name, depo)
If say = 1 Then
varm2 = True
depo1 = syf.Name
End If
Next
With Workbooks("BOYAMA LİSTESİ").Worksheets("SF")
If varm2 Then
.copy before:=Workbooks(bugun).Worksheets(depo1)
Workbooks(bugun).Worksheets("SF").Name = sayfadi
Else
.copy before:=Workbooks(bugun).Worksheets(1)
Workbooks(bugun).Worksheets("SF").Name = sayfadi
End If
End With
For i = 19 To 47 Step 2
If Workbooks(bugun).Worksheets(sayfadi).Cells(i, 1).Value = "" Then
With Workbooks(bugun).Worksheets(sayfadi)
.Cells(i, 1).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 3).Value
.Cells(i, 4).Value = depo
.Cells(i, 5).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 6).Value
.Cells(i, 6).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 8).Value
.Cells(i, 10).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), 18).Value
.Cells(6, 2).Value = depo
.Cells(12, 8).Value = bugun
If c Then
.Cells(13, 2).Value = "%20 İŞ ARTIŞI"
End If
End With
With ActiveSheet.Range("a" + CStr(i - 2) + ":" + "j" + CStr(i + 1))
.Borders.LineStyle = xlNone
.Borders.LineStyle = xlContinuous
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlEdgeLeft).TintAndShade = 0
.Borders(xlEdgeTop).TintAndShade = 0
.Borders(xlEdgeBottom).TintAndShade = 0
.Borders(xlEdgeRight).TintAndShade = 0
.Borders(xlEdgeLeft).ColorIndex = 0
.Borders(xlEdgeTop).ColorIndex = 0
.Borders(xlEdgeBottom).ColorIndex = 0
.Borders(xlEdgeRight).ColorIndex = 0
End With
Exit For
Else
End If
Next i
Workbooks(bugun).Save
End If
End If
label1:
Else: MsgBox ("lütfen tek hücre seçiniz")
End If
label3:
Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Activate
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
End Sub
Sub kismisipariş()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Dim c As Boolean
If Selection.Cells.Count = 1 Then
Dim s As String, t As String, y As String, m1 As Integer, d1 As Date
s = ActiveCell.Row
t = ActiveCell.Column
If Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), (CInt(t))).Value > _
Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), 17).Value Then
b = MsgBox("sipariş kalan miktarı aştı eminmisiniz", vbYesNo)
If b = vbYes Then
c = True
GoTo label0
Else
ActiveCell.Value = 0
Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), 18).Value = 0
GoTo label1
End If
End If
label0:
' With Selection.Interior
' .Pattern = xlSolid
' .PatternColorIndex = xlAutomatic
' .Color = 255
' .TintAndShade = 0
' .PatternTintAndShade = 0
' End With
' Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), (CInt(t) + 1)).Value = Date
' Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), 18).Value = ActiveCell.Value
d1 = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(CInt(s), (CInt(t) + 1)).Value
m1 = ActiveCell.Value
siparisiYesilBoya.yesil1
Dim path As String, depo As String, ihaleadi As String, sayfadi As String, bugun As String
bugun = DateTime.Date
'path = "D:\BOYAMA\SİPARİŞ\" & CStr(DateTime.Date) & ".xlsx"
path = "D:\BOYAMA\KISMİSİPARİŞ\" & CStr(DateTime.Date) & ".xlsx"
depo = CStr(Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 4).Value)
ihaleadi = Mid(CStr(Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 2).Value), 6, 10)
If c Then
sayfadi = depo + "-" + ihaleadi + "++%20"
Else
sayfadi = depo + "-" + ihaleadi
End If
If Dir(path) = "" Then
Workbooks("BOYAMA LİSTESİ").Worksheets("SF").copy
ActiveWorkbook.SaveAs path
ActiveWorkbook.Worksheets("SF").Name = sayfadi
For i = 19 To 47 Step 2
If Workbooks(bugun).Worksheets(sayfadi).Cells(i, 1).Value = "" Then 'eğer dosyada bugün tarihli bir sipariş yoksa
With Workbooks(bugun).Worksheets(sayfadi)
.Cells(i, 1).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 3).Value
.Cells(i, 4).Value = depo
.Cells(i, 5).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 6).Value
.Cells(i, 6).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 8).Value
.Cells(i, 10).Value = m1
.Cells(6, 2).Value = depo
.Cells(12, 8).Value = d1
If c Then
.Cells(13, 2).Value = "%20 İŞ ARTIŞI"
End If
End With
With ActiveSheet.Range("a" + CStr(i - 2) + ":" + "j" + CStr(i + 1))
.Borders.LineStyle = xlNone
.Borders.LineStyle = xlContinuous
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlEdgeLeft).TintAndShade = 0
.Borders(xlEdgeTop).TintAndShade = 0
.Borders(xlEdgeBottom).TintAndShade = 0
.Borders(xlEdgeRight).TintAndShade = 0
.Borders(xlEdgeLeft).ColorIndex = 0
.Borders(xlEdgeTop).ColorIndex = 0
.Borders(xlEdgeBottom).ColorIndex = 0
.Borders(xlEdgeRight).ColorIndex = 0
End With
Exit For
Else
End If
Next i
Workbooks(bugun).Save
Else 'eğer bugün tarihli bir sipariş exceli varsa
Dim kitap As Workbook
Dim acıkmı As Boolean
For Each kitap In Workbooks
If kitap.Name = bugun + ".xlsx" Then
acıkmı = True
Else
End If
Next
If acıkmı = False Then
Workbooks.Open Filename:=path
End If
Dim varmi As Boolean
For i = 1 To Workbooks(bugun).Sheets.Count
If Workbooks(bugun).Sheets(i).Name = sayfadi Then
varmi = True
Exit For
Else
' varmi = False
End If
Next i
If varmi Then 'eğer bugün tarih tarihli bir excelde bu depo+ihale adlı sipariş varsa
Dim var1 As Boolean, var2 As Boolean
Dim m As Integer
For n = 19 To 47 Step 2
With Workbooks(bugun).Worksheets(sayfadi)
If .Cells(n, 1).Value = "" Then
Exit For
Else
If .Cells(n, 5).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 6).Value _
And .Cells(n, 10).Value = m1 Then
var1 = True
ElseIf .Cells(n, 5).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 6).Value _
And .Cells(n, 10).Value <> m1 Then
var2 = True
m = n
Else
End If
End If
End With
Next n
If var1 Then
MsgBox ("bu siparişten var")
GoTo label3
ElseIf var2 Then
Workbooks(bugun).Worksheets(sayfadi).Cells(m, 10).Value = m1
MsgBox ("sipariş miktarı başarı ile güncellendi")
Else
For i = 19 To 47 Step 2
If Workbooks(bugun).Worksheets(sayfadi).Cells(i, 1).Value = "" Then
With Workbooks(bugun).Worksheets(sayfadi)
.Cells(i, 1).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 3).Value
.Cells(i, 4).Value = depo
.Cells(i, 5).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 6).Value
.Cells(i, 6).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 8).Value
.Cells(i, 10).Value = m1
End With
With Workbooks(bugun).Worksheets(sayfadi).Range("a" + CStr(i - 2) + ":" + "j" + CStr(i + 1))
.Borders.LineStyle = xlNone
.Borders.LineStyle = xlContinuous
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlEdgeLeft).TintAndShade = 0
.Borders(xlEdgeTop).TintAndShade = 0
.Borders(xlEdgeBottom).TintAndShade = 0
.Borders(xlEdgeRight).TintAndShade = 0
.Borders(xlEdgeLeft).ColorIndex = 0
.Borders(xlEdgeTop).ColorIndex = 0
.Borders(xlEdgeBottom).ColorIndex = 0
.Borders(xlEdgeRight).ColorIndex = 0
End With
Exit For
Else
End If
Next i
Workbooks(bugun).Save
End If
Else 'eğer bugün tarih tarihli bir excelde bu depo+ihale adlı sipariş yoksa
Dim syf As Worksheet
Dim say As Integer
Dim varm2 As Boolean
Dim depo1 As String
For Each syf In Workbooks(bugun).Worksheets
say = InStr(syf.Name, depo)
If say = 1 Then
varm2 = True
depo1 = syf.Name
End If
Next
With Workbooks("BOYAMA LİSTESİ").Worksheets("SF")
If varm2 Then
.copy before:=Workbooks(bugun).Worksheets(depo1)
Workbooks(bugun).Worksheets("SF").Name = sayfadi
Else
.copy before:=Workbooks(bugun).Worksheets(1)
Workbooks(bugun).Worksheets("SF").Name = sayfadi
End If
End With
For i = 19 To 47 Step 2
If Workbooks(bugun).Worksheets(sayfadi).Cells(i, 1).Value = "" Then
With Workbooks(bugun).Worksheets(sayfadi)
.Cells(i, 1).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 3).Value
.Cells(i, 4).Value = depo
.Cells(i, 5).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 6).Value
.Cells(i, 6).Value = Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Cells(s, 8).Value
.Cells(i, 10).Value = m1
.Cells(6, 2).Value = depo
.Cells(12, 8).Value = d1
If c Then
.Cells(13, 2).Value = "%20 İŞ ARTIŞI"
End If
End With
With ActiveSheet.Range("a" + CStr(i - 2) + ":" + "j" + CStr(i + 1))
.Borders.LineStyle = xlNone
.Borders.LineStyle = xlContinuous
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlEdgeLeft).TintAndShade = 0
.Borders(xlEdgeTop).TintAndShade = 0
.Borders(xlEdgeBottom).TintAndShade = 0
.Borders(xlEdgeRight).TintAndShade = 0
.Borders(xlEdgeLeft).ColorIndex = 0
.Borders(xlEdgeTop).ColorIndex = 0
.Borders(xlEdgeBottom).ColorIndex = 0
.Borders(xlEdgeRight).ColorIndex = 0
End With
Exit For
Else
End If
Next i
Workbooks(bugun).Save
End If
End If
label1:
Else: MsgBox ("lütfen tek hücre seçiniz")
End If
label3:
Workbooks("BOYAMA LİSTESİ").Worksheets("BOYA").Activate
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
End Sub