View Single Post
  #1 (permalink)  
Old March 21st, 2005, 12:34 AM
mateenmohd mateenmohd is offline
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default vb macro output file to excel

Please can remove the error from following coding
it give error line 30 .... OR

It display the missing / un-match values how ?

what is the missing or what is wrong ?

Please help.




Sub SYNCdataSort()

' SYNCdataSort Macro
' For automated input of volume in Synchro format


a = 4

Sheets("synchro").Select

Do Until IsEmpty(Cells(a, 3)) = True

intid = Cells(a, 3)

b = 3
Sheets("base").Select
Do Until IsEmpty(Cells(b, 1)) = True
If Cells(b, 1) = intid Then datid = Cells(b, 2): Exit Do Else b = b + 1
Loop
If Not Cells(b, 1) = intid Then
msg = "Intersection ID not found, please check BASE sheet"
Style = vbOKOnly
Title = Cells(b, 1)
response = MsgBox(msg, Style, Title)
End
End If

Sheets("IDs for AVOL").Select
p = 1
Do Until IsEmpty(Cells(p, 1)) = True
If Cells(p, 1) = intid Then idchk = intid: GoTo 20 Else p = p + 1
Loop

c = 3
Sheets("MTP").Select
Do Until IsEmpty(Cells(c, 2)) = True
If Cells(c, 2) = datid Then GoTo 10 Else c = c + 1
Loop
If Not Cells(c, 2) = datid Then
msg = "Intersection ID not found, please check output Data Sheet"
Style = vbOKOnly
Title = Cells(b, 1)
response = MsgBox(msg, Style, Title)
End
End If

10 d = 3
m = Cells(2, d) 'movement
v = Cells(c, d) 'volume
Dim mov(15), vol(15) As Variant
For j = 0 To 15
mov(j) = m
vol(j) = v
d = d + 1
m = Cells(2, d) 'movement
v = Cells(c, d) 'volume
Next j

Sheets("Synchro").Select
e = 4
For j = 0 To 15
Do Until Cells(3, e) = mov(j) = True
e = e + 1
Loop
Cells(a, e) = vol(j)
e = 4
Next j
GoTo 100

20 Sheets("base").Select
f = 28
h = 28
Do Until Cells(f, 1) = idchk = True
h = h + 1
f = f + 1
Loop
g = 0 ' record for no. of movements
Do While Cells(h, 1) = idchk = True
h = h + 1
g = g + 1
Loop
msync = Cells(f, 3) 'movement synchro
mdata = Cells(f, 4) 'equivalent data movement
Dim ms(100), md(100) As Variant
For k = 0 To (g - 1)
'value of g minus one bec. array considers 0 as record number one
ms(k) = msync 'movement synchro
md(k) = mdata 'equivalent data movement
f = f + 1
msync = Cells(f, 3) 'movement synchro
mdata = Cells(f, 4) 'equivalent data movement
Next k

c = 3
Sheets("MTP").Select
Do Until IsEmpty(Cells(c, 2)) = True
If Cells(c, 2) = datid Then GoTo 30 Else c = c + 1
Loop
If Not Cells(c, 2) = datid Then
msg = "Intersection ID not found, please check output Data Sheet"
Style = vbOKOnly
Title = Cells(b, 1)
response = MsgBox(msg, Style, Title)
End
End If

30 d = 3
Dim avol(100) As Variant
For k = 0 To (g - 1)
Do Until Cells(2, d) = md(k) = True 'using movement code in output data
(error is this line, on this line is stop)

d = d + 1
Loop
avol(k) = Cells(c, d) 'volume for abnormal geometry
d = 3
Next k

Sheets("synchro").Select
e = 4
For k = 0 To (g - 1)
Do Until Cells(3, e) = ms(k) = True 'using Synchro movement code
e = e + 1
Loop
Cells(a, e) = avol(k)
e = 4
Next k

100 a = a + 1
Loop

End Sub


can anybody can help me, I will send Excel file to your e.mail address
(you can give post your e.mail address here)

regards

Mateen
[email protected]

Reply With Quote