-
Notifications
You must be signed in to change notification settings - Fork 0
/
Waterland General UU Drawing
1301 lines (1035 loc) · 38 KB
/
Waterland General UU Drawing
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Dim wb As Workbook
Dim wbmain As Workbook
Dim wbUU As Workbook
Dim c As Integer
Dim UUc As Integer
Dim textData As String
Dim wbcon As Workbook
Dim cCon As Integer
Public Function IsInArray(stringToBeFound As String, arr As Variant) As Boolean
Dim i
For i = LBound(arr) To UBound(arr)
If arr(i) = stringToBeFound Then
IsInArray = True
Exit Function
End If
Next i
IsInArray = False
End Function
Function GetFolder() As String
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = Application.DefaultFilePath
If .Show <> -1 Then GoTo NextCode
sItem = .SelectedItems(1)
End With
NextCode:
GetFolder = sItem
Set fldr = Nothing
End Function
Private Sub checkErrors_Click()
Dim checkxRange As Range
Dim xCell As Range
Dim checkendRange As Range
Dim endCell As Range
Dim xindex As Integer
Dim endindex As Integer
Dim errorValue As String
Dim wsDest As Worksheet
Dim lDestLastRow As Long
Dim i As Long
Dim col1 As Long
Dim col2 As Long
Dim col3 As Long
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
'CG errors
Set wsDest = ThisWorkbook.Worksheets("AutoImport")
Set checkendRange = wbmain.Worksheets("x").Range("A:A")
For Each endCell In checkendRange
If endCell.Value = "" Then
endindex = endCell.Row
Exit For
End If
Next endCell
i = 0
Set checkxRange = wbmain.Worksheets("x").Range("F1:F" & endindex - 1)
For Each xCell In checkxRange
If WorksheetFunction.IsNA(xCell) Then
xindex = xCell.Row
errorValue = wbmain.Worksheets("x").Range("A" & xindex).Value
lDestLastRow = wbmain.Worksheets("CG").Cells(wbmain.Worksheets("CG").Rows.Count, "C").End(xlUp).Offset(1).Row
col1 = wbmain.Worksheets("CG").Range("C" & lDestLastRow - 1) - 350
col2 = wbmain.Worksheets("CG").Range("D" & lDestLastRow - 1) - 350
col3 = wbmain.Worksheets("CG").Range("E" & lDestLastRow - 1) + 2
wbmain.Worksheets("CG").Range("B" & lDestLastRow) = errorValue
wbmain.Worksheets("CG").Range("C" & lDestLastRow) = i + col1
wbmain.Worksheets("CG").Range("D" & lDestLastRow) = i + col2
wbmain.Worksheets("CG").Range("E" & lDestLastRow) = i + col3
i = i + 2
wbmain.Worksheets("CG").Range("B" & lDestLastRow).Interior.ColorIndex = 6
wbmain.Worksheets("CG").Range("C" & lDestLastRow).Interior.ColorIndex = 6
wbmain.Worksheets("CG").Range("D" & lDestLastRow).Interior.ColorIndex = 6
wbmain.Worksheets("CG").Range("E" & lDestLastRow).Interior.ColorIndex = 6
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "E").End(xlUp).Offset(1).Row
If wsDest.Range("E4") = "" Then
wsDest.Range("E4") = errorValue & " is missing coordinates."
Else: wsDest.Range("E" & lDestLastRow) = errorValue & " is missing coordinates."
End If
End If
Next xCell
'TC errors
Dim lastRowE As Integer
Dim lastRowF As Integer
Dim foundTrue As Boolean
lastRowE = wbmain.Worksheets("CG").Cells(wbmain.Worksheets("CG").Rows.Count, "B").End(xlUp).Row
lastRowF = wbmain.Worksheets("TC").Cells(wbmain.Worksheets("TC").Rows.Count, "B").End(xlUp).Row
For i = 1 To lastRowE
foundTrue = False
For j = 1 To lastRowF
If wbmain.Worksheets("CG").Cells(i, 9).Value = wbmain.Worksheets("TC").Cells(j, 2).Value Then
foundTrue = True
Exit For
End If
Next j
If Not foundTrue Then
If InStr(wbmain.Worksheets("CG").Cells(i, 9), "J") = 0 And InStr(wbmain.Worksheets("CG").Cells(i, 9), "R") = 0 And InStr(wbmain.Worksheets("CG").Cells(i, 9), "SB") = 0 Then
If InStr(wbmain.Worksheets("CG").Cells(i, 9), "CW") = 0 And InStr(wbmain.Worksheets("CG").Cells(i, 9), "I") = 0 And InStr(wbmain.Worksheets("CG").Cells(i, 9), "HDN") = 0 Then
'MsgBox ("didnt find string: " & Sheets("E Dump").Cells(i, 2).value)
errorValue = wbmain.Worksheets("CG").Cells(i, 9).Value
'Astro DONT WANT
'lDestLastRow = wbmain.Worksheets("TC").Cells(wbmain.Worksheets("TC").Rows.Count, "B").End(xlUp).Offset(1).Row
'wbmain.Worksheets("TC").Range("B" & lDestLastRow).Value = errorValue
'wbmain.Worksheets("TC").Range("C" & lDestLastRow).Value = "U"
'wbmain.Worksheets("TC").Range("B" & lDestLastRow).Interior.ColorIndex = 6
'wbmain.Worksheets("TC").Range("C" & lDestLastRow).Interior.ColorIndex = 6
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "F").End(xlUp).Offset(1).Row
If wsDest.Range("F4") = "" Then
wsDest.Range("F4") = errorValue & " is missing from TC."
Else: wsDest.Range("F" & lDestLastRow) = errorValue & " is missing from TC."
End If
End If
End If
End If
Next i
'connections missing
Set checkendRange = wbmain.Worksheets("x").Range("A:A")
For Each endCell In checkendRange
If endCell.Value = "" Then
endindex = endCell.Row
Exit For
End If
Next endCell
i = 0
Set checkxRange = wbmain.Worksheets("x").Range("O1:O" & endindex - 1)
For Each xCell In checkxRange
If WorksheetFunction.IsNA(xCell) Or xCell.Text = "0" Then
xindex = xCell.Row
errorValue = wbmain.Worksheets("x").Range("A" & xindex).Value
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "G").End(xlUp).Offset(1).Row
If wsDest.Range("G4") = "" Then
wsDest.Range("G4") = errorValue & " is missing connection."
Else: wsDest.Range("G" & lDestLastRow) = errorValue & " is missing connection."
End If
End If
Next xCell
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
MsgBox "Complete", vbInformation
End Sub
Private Sub CommandButton1_Click()
Application.Visible = True
Dim FileLocation As String
FileLocation = Application.GetOpenFilename()
Dim check As String
check = Dir(FileLocation)
If check <> "" Then
Set wb = Workbooks.Open(FileLocation)
wb.Windows(1).Visible = False
c = wb.Sheets.Count
' fix_undefined problem and add xx# on missing values
i = 1
For W = 1 To c Step 1
For x = 1 To 15 Step 2
Set checkRange = wb.Worksheets(W).Range(Chr(64 + x) & "12:" & Chr(64 + x) & "36")
Set myRange = wb.Worksheets(W).Range(Chr(64 + x + 1) & "12:" & Chr(64 + x + 1) & "36")
counter = 0
For Each mycheckCell In checkRange
If Not IsEmpty(mycheckCell.Value) Then
counter = counter + 1
myRange.Cells(counter).Replace What:="undefined", Replacement:="", MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
myRange.Cells(counter).Replace What:=" ", Replacement:="", MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
myRange.Cells(counter).Replace What:="Other", Replacement:="", MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
If IsEmpty(myRange.Cells(counter).Value) Then
myRange.Cells(counter).Value = "x" & i
i = i + 1
End If
End If
Next mycheckCell
Next x
Next W
Me.Label1 = wb.Name
CommandButton3.Enabled = True
End If
End Sub
Private Sub CommandButton10_Click()
'Sorting
With wbmain.Worksheets("CG").Sort
.SortFields.Add Key:=Range("A1"), Order:=xlAscending
.SetRange Range("A1:I" & wbmain.Worksheets("CG").Range("A" & Rows.Count).End(xlUp).Row)
.Header = xlNo
.Apply
End With
CommandButton1.Enabled = True
End Sub
Private Sub CommandButton11_Click()
End Sub
Private Sub CommandButton2_Click()
Dim check As String
Dim TopoFileLocation As String
TopoFileLocation = Application.GetOpenFilename()
check = Dir(TopoFileLocation)
If check <> "" Then
Set wbmain = Workbooks.Open(TopoFileLocation)
MsgBox "Selected Topo File Successfully", vbInformation
Me.Label2 = wbmain.Name
Windows(wbmain.Name).Visible = True
End If
End Sub
Private Sub CommandButton3_Click()
'Copy survey data
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
Dim Count As Integer
Dim myRange As Range
Dim myCell As Range
Dim i As Integer
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Set wsDest = wbmain.Worksheets("CG")
For W = 1 To c Step 1
'Set variables for copy and destination sheets
Set wsCopy = wb.Worksheets(W)
For x = 2 To 16 Step 2
'1. Find last used row in the copy range based on data in column B
'lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "B").End(xlUp).Row
'2. Find first blank row in the destination range based on data in column B
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "B").End(xlUp).Offset(1).Row
'3. Copy & Paste Data
wsCopy.Range(Chr(64 + x) & "12:" & Chr(64 + x) & "36").Copy
If wsDest.Range("B1") = "" Then
wsDest.Range("B1").PasteSpecial paste:=xlPasteValues
Else: wsDest.Range("B" & lDestLastRow).PasteSpecial paste:=xlPasteValues
End If
'wsCopy.Range("B12:B36", "D12:D36", "F12:F36", "H12:H36", "J12:J36", "L12:L36", "N12:N36", "P12:P36").Copy
Next x
Next W
'fix G and J values
Dim checkSRange As Range
Dim sCell As Range
Dim str As String
Dim sindex As Integer
Set checkSRange = wbmain.Worksheets("CG").Range("B:B")
For Each sCell In checkSRange
'If InStr(sCell.Value, "G") > 2 Then
If Right(sCell.Value, 1) = "G" Or Right(sCell.Value, 1) = "g" Then
sCell.Value = Left(sCell.Value, Len(sCell.Value) - 1)
str = sCell.Value
End If
If InStr(sCell.Value, "J") > 0 Or InStr(sCell.Value, "j") > 0 Then
If Left(sCell.Value, 1) = "J" Or Left(sCell.Value, 1) = "j" Then
sCell.Value = str & sCell.Value
sCell.Interior.ColorIndex = 19
ElseIf sCell.Interior.ColorIndex <> 19 Then
sCell.Value = Right(sCell.Value, Len(sCell.Value) - 1)
sCell.Value = str & sCell.Value
sCell.Interior.ColorIndex = 19
End If
End If
Next sCell
ListBox2.AddItem Me.Label1
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
CommandButton3.Enabled = False
wb.Windows(1).Visible = True
wb.Save
wb.Close
MsgBox "Data Imported Successfully", vbInformation
Set wb = Nothing
Me.Label1 = "no file selected..."
End Sub
Private Sub CommandButton4_Click()
Dim UUFileLocation As String
Dim check As String
UUFileLocation = Application.GetOpenFilename()
check = Dir(UUFileLocation)
If check <> "" Then
Set wbUU = Workbooks.Open(UUFileLocation)
wbUU.Windows(1).Visible = False
UUc = wbUU.Sheets.Count
MsgBox "Selected UU File Successfully", vbInformation
Me.Label3 = wbUU.Name
CommandButton5.Enabled = True
End If
End Sub
Private Sub CommandButton5_Click()
'Copy UU data
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
Dim Count As Integer
Dim myRange As Range
Dim myCell As Range
Dim i As Integer
Dim MainIndex As Long
Dim cl As Range
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Set wsDest = wbmain.Worksheets("TC")
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
MainIndex = lDestLastRow
For W = 1 To UUc Step 1
'Set variables for copy and destination sheets
Set wsCopy = wbUU.Worksheets(W)
'2. Find first blank row in the destination range based on data in column B
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
'3. Copy & Paste Data
wsCopy.Range("B11:F40").Copy
If wsDest.Range("A1") = "" Then
wsDest.Range("A1").PasteSpecial paste:=xlPasteValues
Else: wsDest.Range("A" & lDestLastRow).PasteSpecial paste:=xlPasteValues
End If
wsCopy.Range("K11:K40").Copy
If wsDest.Range("F1") = "" Then
wsDest.Range("F1").PasteSpecial paste:=xlPasteValues
Else: wsDest.Range("F" & lDestLastRow).PasteSpecial paste:=xlPasteValues
End If
Next W
' fix symbols
Dim checkSRange As Range
Dim abcd As Integer
Dim fixRange As Range
Dim sCell As Range
Dim bCell As Range
Dim sindex As Integer
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
Dim dic As Object: Set dic = CreateObject("Scripting.Dictionary")
dic.comparemode = vbTextCompare
Dim dKey
For Each dKey In Split("V FH WM N LM S Y CP IN OUT END G H")
dic.Add dKey, Nothing
Next dKey
Set checkSRange = wsDest.Range("E" & MainIndex & ":E" & lDestLastRow - 1)
For Each cl In checkSRange 'checkSRange
If Not dic.exists(Trim(cl)) Then
cl.Value = ""
End If
Next cl
Set checkSRange = wsDest.Range("B" & MainIndex & ":B" & lDestLastRow - 1)
For Each bCell In checkSRange
If bCell.Value = "" Then
bCell.Value = "U"
ElseIf IsNumeric(bCell.Value) Then
bCell = CDec(bCell)
End If
If bCell.Value = "0" Then
bCell.Value = "E"
End If
Next bCell
'fix user input accidents in symbols
i = 0
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
Set dic = CreateObject("Scripting.Dictionary")
dic.comparemode = vbTextCompare
For Each dKey In Split("AV BV GV AFH BFH AWM BWM GN ALM PLM LLM MLM CLM HLM KLM TLM WLM ELM NLM PS LS MS CS HS KS WS TS ES NS SY SCP SIN SOUT END AG BG GG PG LG MH CG DG HG KG TG WG EG XG NG UG FG SG")
dic.Add dKey, Nothing
Next dKey
For i = 2 To lDestLastRow - 1
If Not dic.exists(Trim(Left$(wsDest.Cells(i, 1), 1) & wsDest.Cells(i, 5))) Then
wsDest.Cells(i, 5).Value = ""
End If
Next i
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
MsgBox "Data Imported Successfully", vbInformation
wbUU.Windows(1).Visible = True
wbUU.Close SaveChanges:=True
ListBox3.AddItem Me.Label3
Set wbUU = Nothing
Me.Label3 = "no file selected..."
CommandButton5.Enabled = False
End Sub
Private Sub CommandButton6_Click()
Dim textFileNum As Integer
Dim textFileLocation, textDelimiter As String
Dim tArray() As String
Dim sArray() As String
Dim textFileName As String
Dim check As String
textFileLocation = Application.GetOpenFilename()
If textFileLocation <> "False" Then
textFileName = Dir(textFileLocation)
textFileNum = FreeFile
Open textFileLocation For Input As textFileNum
textData = Input(LOF(textFileNum), textFileNum)
Close textFileNum
Me.Label5 = textFileName
CommandButton7.Enabled = True
End If
End Sub
Private Sub CommandButton7_Click()
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Dim rowNum, colNum As Integer
Dim textDelimiter As String
Dim tArray() As String
Dim sArray() As String
Dim lDestLastRow As Long
Dim inte As Integer
inte = 0
Application.ScreenUpdating = False
textDelimiter = ","
tArray() = Split(textData, vbLf)
For rowNum = LBound(tArray) To UBound(tArray) - 2
If Len(Trim(tArray(rowNum))) <> 0 Then
sArray = Split(tArray(rowNum), textDelimiter)
wbmain.Worksheets("CG").[A1] = sArray(1)
' if fist cell is empty and first check if same cells
'If inte = 0 Then
'On Error GoTo ErrorHandler
If wbmain.Worksheets("CG").Cells(1, 3) = "" Then
wbmain.Worksheets("CG").Cells(rowNum + 1, 1) = sArray(0)
For colNum = LBound(sArray) + 1 To UBound(sArray)
wbmain.Worksheets("CG").Cells(rowNum + 1, colNum + 2) = sArray(colNum)
Next colNum
ElseIf Round(wbmain.Worksheets("CG").Cells(1, 3), 3) = Round(sArray(1), 3) Then
MsgBox "Similar Data Found", vbInformation
GoTo Labelx
Else:
lDestLastRow = wbmain.Worksheets("CG").Cells(wbmain.Worksheets("CG").Cells.Rows.Count, "A").End(xlUp).Row
wbmain.Worksheets("CG").Cells(lDestLastRow + 1, 1) = sArray(0)
For colNum = LBound(sArray) + 1 To UBound(sArray)
wbmain.Worksheets("CG").Cells(lDestLastRow + 1, colNum + 2) = sArray(colNum)
Next colNum
End If
End If
Next rowNum
If inte = 1 Then
Labelx:
For rowNum = LBound(tArray) To UBound(tArray) - 2
sArray = Split(tArray(rowNum), textDelimiter)
wbmain.Worksheets("CG").Cells(rowNum + 1, 1) = sArray(0)
For colNum = LBound(sArray) + 1 To UBound(sArray)
wbmain.Worksheets("CG").Cells(rowNum + 1, colNum + 2) = sArray(colNum)
Next colNum
Next rowNum
End If
' extend_cg1 Macro and delete extra rows
'If wbmain.Worksheets("CG").Cells(lDestLastRow + 1, 1) <> "" Then
' wbmain.Worksheets("CG").Cells(lDestLastRow + 1, 1) = ""
'End If
Dim checkRange As Range
Dim myCell As Range
Dim index As Integer
Set checkRange = wbmain.Worksheets("CG").Range("C:C")
For Each myCell In checkRange
If IsEmpty(myCell.Value) Or myCell.Value = " " Then
index = myCell.Row
Exit For
End If
Next myCell
wbmain.Worksheets("CG").Range("F1:F" & index - 1).Value = "text"
wbmain.Worksheets("CG").Range("B" & index & ":B" & index + 200).Value = ""
wbmain.Worksheets("CG").Range("H1:H2").AutoFill Destination:=wbmain.Worksheets("CG").Range("H1:H" & index - 1), Type:=xlFillCopy
wbmain.Worksheets("CG").Range("G1:G2").AutoFill Destination:=wbmain.Worksheets("CG").Range("G1:G" & index - 1), Type:=xlFillDefault
wbmain.Worksheets("CG").Range("I1:I2").AutoFill Destination:=wbmain.Worksheets("CG").Range("I1:I" & index - 1), Type:=xlFillDefault
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
CommandButton7.Enabled = False
ListBox1.AddItem Me.Label5
Me.Label5 = "no file selected..."
textData = ""
MsgBox "Data Imported Successfully", vbInformation
End Sub
Private Sub CommandButton9_Click()
Dim ConFileLocation As String
ConFileLocation = Application.GetOpenFilename()
Dim check As String
check = Dir(ConFileLocation)
If check <> "" Then
Set wbcon = Workbooks.Open(ConFileLocation)
wbcon.Windows(1).Visible = False
cCon = wbcon.Sheets.Count
MsgBox "Selected Conntectivity File Successfully", vbInformation
Me.Label7 = wbcon.Name
CommandButton8.Enabled = True
End If
End Sub
Private Sub CommandButton8_Click()
Dim wsDest As Worksheet
Dim myCRange As Range
Dim cCell As Range
Dim cindex As Integer
Application.ScreenUpdating = False
Set wsDest = wbmain.Worksheets("LX-Input Sort")
Set checkCRange = wbcon.Worksheets(1).Range("A:A")
For Each cCell In checkCRange
If IsEmpty(cCell.Value) Or cCell.Value = " " Then
cindex = cCell.Row
Exit For
End If
Next cCell
wbcon.Worksheets(1).Range("A1:T" & cindex).Copy
wsDest.Range("E1").PasteSpecial paste:=xlPasteValues
Dim checkRange As Range
Dim myCell As Range
Dim index As Integer
Set checkRange = wbmain.Worksheets("LX-Input Sort").Range("E:E")
For Each myCell In checkRange
If IsEmpty(myCell.Value) Or myCell.Value = " " Then
index = myCell.Row
Exit For
End If
Next myCell
'Sorting
Dim checkSRange As Range
Dim sCell As Range
Dim sindex As Integer
Dim introws As Range
Dim lRow As Long, m As Long
sindex = -1
Set checkSRange = wbmain.Worksheets("LX-Input Sort").Range("E:E")
For Each sCell In checkSRange
If InStr(sCell.Value, "A") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "B") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "G") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "P") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "L") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "M") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "C") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "H") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "K") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "T") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "W") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "E") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "N") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "S") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "D") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "X") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "U") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
If sindex = -1 Then
For Each sCell In checkSRange
If InStr(sCell.Value, "F") > 0 Then
sindex = sCell.Row
Exit For
End If
Next sCell
End If
wbmain.Worksheets("LX-Input Sort").Range("E1:X1").Copy
wbmain.Worksheets("LX-Input Sort").Range("Z1:AS1").PasteSpecial paste:=xlPasteValues
wbmain.Worksheets("LX-Input Sort").Range("E" & sindex & ":X" & sindex).Copy
wbmain.Worksheets("LX-Input Sort").Range("E1:X1").PasteSpecial paste:=xlPasteValues
wbmain.Worksheets("LX-Input Sort").Range("Z1:AS1").Copy
wbmain.Worksheets("LX-Input Sort").Range("E" & sindex & ":X" & sindex).PasteSpecial paste:=xlPasteValues
wbmain.Worksheets("LX-Input Sort").Range("Z1:AS1").ClearContents
With wbmain.Worksheets("LX-Input Sort").Sort
.SortFields.Add Key:=Range("A1"), Order:=xlAscending
.SetRange Range("A1:X" & index - 1)
.Header = xlNo
.Apply
End With
wbmain.Worksheets("LX-Input Sort").Range("E1:X" & wbmain.Worksheets("LX-Input Sort").Range("E" & Rows.Count).End(xlUp).Row).Copy
wbmain.Worksheets("LX-Input").Range("E1").PasteSpecial paste:=xlPasteValues
' extend_lx Macro
Set checkRange = wbmain.Worksheets("LX-Input").Range("E:E")
For Each myCell In checkRange
If IsEmpty(myCell.Value) Or myCell.Value = " " Then
index = myCell.Row
Exit For
End If
Next myCell
wbmain.Worksheets("LX-Input").Range("A1:A2").AutoFill Destination:=wbmain.Worksheets("LX-Input").Range("A1:A" & index - 1), Type:=xlFillDefault
wbmain.Worksheets("LX-Input").Range("B1:B2").AutoFill Destination:=wbmain.Worksheets("LX-Input").Range("B1:B" & index - 1), Type:=xlFillDefault
wbmain.Worksheets("LX-Input").Range("C1:C2").AutoFill Destination:=wbmain.Worksheets("LX-Input").Range("C1:C" & index - 1), Type:=xlFillDefault
wbmain.Worksheets("LX-Input").Range("D2:D3").AutoFill Destination:=wbmain.Worksheets("LX-Input").Range("D2:D" & index - 1), Type:=xlFillDefault
wbmain.Worksheets("LX-Input Sort").Range("E1:X" & wbmain.Worksheets("LX-Input Sort").Range("E" & Rows.Count).End(xlUp).Row).ClearContents
wbcon.Windows(1).Visible = True
wbcon.Save
wbcon.Close
Application.ScreenUpdating = True
MsgBox "Data Imported Successfully", vbInformation
Set wbcon = Nothing
ListBox4.AddItem Me.Label7
Me.Label7 = "no file selected..."
CommandButton8.Enabled = False
End Sub
Private Sub generateScripts_Click()
Dim FolderName As String
FolderName = GetFolder()
If FolderName = "" Then
MsgBox "No folder was selected. Program will terminate."
Exit Sub
End If
Application.ScreenUpdating = False
Dim wbO As Workbook
Dim wsI As Worksheet, wsO As Worksheet
Dim bigtemp As String
'Dim cArray("A", "B", "G", "P", "L", "M", "C", "H", "K", "T", "W", "E", "N", "S", "D", "X", "U", "F") As String
bigtemp = ""
'~~> Set the relevant sheet from where you want to copy
Set wsI = wbmain.Sheets("JXB-0")
Dim fRange As Range
Dim fCell As Range
Dim findex As Integer
Set fRange = wsI.Range("B:B")
For Each fCell In fRange
If WorksheetFunction.IsNA(fCell) Then
findex = fCell.Row - 1
Exit For
End If
Next fCell
'~~> Destination/Output Workbook
Set wbO = Workbooks.Add
With wbO
'~~> Set the relevant sheet to where you want to paste
wbO.Sheets("Sheet1").Name = "0"
Set wsO = wbO.Sheets("0")
'~~>. Save the file
.SaveAs Filename:=FolderName & "\" & "0.csv"
'~~> Copy the range
wsI.Range("A1:E" & findex).Copy
'~~> Paste it in say Cell A1. Change as applicable
wsO.Range("A1").PasteSpecial paste:=xlPasteValues
End With
wbO.Save
wbO.Close
' depth Macro
Dim fName As String
Dim sh As Worksheet, nFileNum As Integer
Dim paste As String
Dim myFolder As String
wbmain.Worksheets("depth").Activate
Set sh = wbmain.Worksheets("depth")
On Error Resume Next
sh.Range("A1:J" & sh.Range("J" & Rows.Count).End(xlUp).Row).AutoFilter Field:=10, Criteria1:=Array( _
"A", "B", "G", "P", "L", "M", "C", "H", "K", "T", "W", "E", "N", "S", "D", "X", "U", "F", "Z"), Operator:= _
xlFilterValues
sh.Range("C1:I" & sh.Range("C" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select
'This temporarily adds a sheet named "Test."
'wbmain.Sheets.Add.Name = "Test"
'Sheets("Test").Select
'ActiveSheet.paste
''''''''''''''''''''''
'Save selected data as text file in users selected folder.
'ActiveWorkbook.SaveAs Filename:="depth.scr", FileFormat:=xlText, CreateBackup:=False
'Remove temporary sheet.
Dim r As Range, c As Range
Dim sTemp As String
Open FolderName & "\" & "depth.scr" For Output As #1
For Each r In Selection.Rows
sTemp = ""
For Each c In r.Cells
sTemp = sTemp & c.Text & Chr(9)
Next c
sTemp = Left(sTemp, Len(sTemp) - 1)
bigtemp = bigtemp & sTemp & Chr(10)
Print #1, sTemp
Next r
Close #1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
wbmain.Worksheets("line").Activate
Set sh = wbmain.Worksheets("line")
Dim FindRow As Range
Dim findexText As String
Dim orange As Range
Dim ocell As Range
Set fRange = wbmain.Sheets("LX-RM").Range("A1:A1000")
Set orange = sh.Range("B1:B" & sh.Range("A" & Rows.Count).End(xlUp).Row)
For Each fCell In fRange
If fCell.DisplayFormat.Interior.ColorIndex = 16 Then
findexText = fCell.Row
For Each ocell In orange
If ocell.Value = findexText Then
sh.Cells(ocell.Row, 25).Value = "130"
Exit For
End If
Next ocell
ElseIf fCell.DisplayFormat.Interior.ColorIndex = 15 Then
findexText = fCell.Row
For Each ocell In orange
If ocell.Value = findexText Then
sh.Cells(ocell.Row, 25).Value = "136"
Exit For
End If
Next ocell
End If
Next fCell