Home > Software engineering >  Exclude VBA
Exclude VBA

Time:09-16

Dear master of VBA,
I'm writing a data processing of VBA, encounter a problem, I don't know how to solve, please help have a look at the code there is a problem?

Data is machine automatically output summary data of a day, but the format is bad to deal with these data, so I put the project into different columns, run a VBA to sort out these data, the data in the attachment, the data for a set of data from 3:00 1 ~ 4:00 PM 1-0, repeat hundreds of the same data in a document, to turn it into a horizontal, a set of data to become a line, a set of data should be placed below the second line, and so on, the similar file has more than 100, all want to summary to list processing

How to modify the code to make each set of data in one line, and all the data in a file?

I this code, run out, each file only left the last set of data,

3:00 1: discharging figure ID 8130 cloth - pillow A3. The cut
3:00 2: the length of the discharging figure 1.06
3:00 3: the width of the discharging figure 1.25
4:3:00 parts number 9
3:00 5: clipping period 2019/11/01
Cutting 3:00 6: start time 8:21:27
3:00 7: cut end time 8:23:24
3:00 8: clipping time 0:01:57
3:00 9: average cutting speed 10.83
3:01 0: clipping distance 14.62
3:01 1: the blade up conversion Angle 140.00
3:01 2: the Angle of the cutting tool transformation 15.00
3:01 3: cutting speed (high speed) 45
3:01 4: cutting speed (slow) 43
22 0:01:53 3:02 7: clipping time
At 4 1-0 5
3:00 1: discharging figure ID 8130 cloth - pillow biggest ut
3:00 2: the length of the discharging figure 0.49
3:00 3: the width of the discharging figure 1.01
3:00 4: part number 3
3:00 5: clipping period 2019/11/01
Cutting 3:00 6: start time 8:28:16
3:00 7: cut end time 8:29:03
3:00 8: clipping time 0:00:47
3:00 9: average cutting speed 9.87
3:01 0: clipping distance 4.93
3:01 1: the blade up conversion Angle 140.00
3:01 2: the Angle of the cutting tool transformation 15.00
3:01 3: cutting speed (high speed) 45
3:01 4: cutting speed (slow) 43
22 0:00:44 3:02 7: clipping time
At 4 1-0 5
3:00 1: discharging figure 1.5 right ID KF2033 cloth. The cut
3:00 2: the length of the discharging figure 3.92
3:00 3: the width of the discharging figure 1.40
4:3:00 parts number 20
3:00 5: clipping period 2019/11/01
Cutting 3:00 6: start time 8:30:01
3:00 7: cut end time 8:36:37
3:00 8: clipping time 0:06:36
3:00 9: average cutting speed 9.29
3:01 0: clipping distance 40.08
3:01 1: the blade up conversion Angle 140.00
3:01 2: the Angle of the cutting tool transformation 15.00
3:01 3: cutting speed (high speed) 45
3:01 4: cutting speed (slow) 43
22 0:06:19 3:02 7: clipping time
At 4 1-0 5

Below is the VBA code:

Sub TEST ()

Dim row As Long
The row=4

Range (" A4: Q30000 "). The Clear


Dim As filePath String
'the filePath="D: \ Marker report"

Sheet1. Select

FilePath=Sheet1. Range (F2). The Value

Dim the fs As New FileSystemObject

Dim f As the File
Dim fo the As Folder
If filePath & lt; & gt; "" Then

The Set fo=fs. GetFolder (filePath)

Dim the text As TextStream

For Each f In fo. Files

Sheet1. Range (" A "& amp; The row). Value=https://bbs.csdn.net/topics/f.Name

Set the text=f.O penAsTextStream ()


While (Not the text. AtEndOfLine)


Str1=text. ReadLine ()


If Left (Str1, 12)="3:00 1: discharging figure of ID" Then

Sheet1. Range (" B "& amp; The row). Value=https://bbs.csdn.net/topics/Right (Str1, Len (Str1) - InStr (1, Str1, ""))

End the If

If Left (Str1, 12)="3:00 2: the length of the discharging figure" Then

Sheet1. Range (" C "& amp; The row). Value=https://bbs.csdn.net/topics/Right (Str1, Len (Str1) - InStr (1, Str1, ""))

End the If

If Left (Str1, 12)="3:00 3: the width of the discharging figure" Then

Sheet1. Range (" D "& amp; The row). Value=https://bbs.csdn.net/topics/Right (Str1, Len (Str1) - InStr (1, Str1, ""))

End the If

If Left (9), Str1="3:00 4: part number" Then

Sheet1. Range (" E "& amp; The row). Value=https://bbs.csdn.net/topics/Right (Str1, Len (Str1) - InStr (1, Str1, ""))

End the If
If Left (Str1, 10)="3:00 5: clipping period" Then

Sheet1. Range (" F "& amp; The row). Value=https://bbs.csdn.net/topics/Trim (Right (Str1, Len (Str1) - InStr (1, Str1, "")))

End the If

If Left (Str1, 12)="cutting 3:00 6: start time" Then

Sheet1. Range (" G "& amp; The row). Value=https://bbs.csdn.net/topics/Trim (Right (Str1, Len (Str1) - InStr (1, Str1, "")))

End the If

If Left (Str1, 12)="3:00 7: cut end time" Then

Sheet1. Range (" H "& amp; The row). Value=https://bbs.csdn.net/topics/Trim (Right (Str1, Len (Str1) - InStr (1, Str1, "")))

End the If

If Left (Str1, 10)="3:00 8: clipping time" Then

Sheet1. Range (" I "& amp; The row). Value=https://bbs.csdn.net/topics/Trim (Right (Str1, Len (Str1) - InStr (1, Str1, "")))

End the If

If Left (Str1, 12)="3:00 9: the average cutting speed" Then

Sheet1. Range (" J "& amp; The row). Value=https://bbs.csdn.net/topics/Right (Str1, Len (Str1) - InStr (1, Str1, ""))

End the If

If Left (Str1, 10)="3:01 0: clipping distance" Then

Sheet1. Range (" K "& amp; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
Prev:VB
  •  Tags:  
  • VBA
  • Related