0% found this document useful (0 votes)
8 views1 page

Code 4

The document contains a VBA script that processes rows in a worksheet by deleting those with specific invalid values. It also renames a column from 'CURRENCY' to 'ID' and generates IDs from a 'CODE' column by extracting the portion before any parentheses. Finally, it restores application settings for alerts and screen updating after the operations are completed.

Uploaded by

uyensakurachan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Code 4

The document contains a VBA script that processes rows in a worksheet by deleting those with specific invalid values. It also renames a column from 'CURRENCY' to 'ID' and generates IDs from a 'CODE' column by extracting the portion before any parentheses. Finally, it restores application settings for alerts and screen updating after the operations are completed.

Uploaded by

uyensakurachan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

For r = lastRow To 2 Step -1

v = UCase(Trim(.Cells(r, varCol).Value & ""))


If v = "" _
Or InStr(v, "NA") > 0 _
Or InStr(v, "INVALID CODE OR EXPRESSION ENTERED") > 0 _
Or InStr(v, "NO DATA AVAILABLE") > 0 _
Or InStr(v, "NO WORLDSCOPE DATA FOR THIS CODE") > 0 _
Or InStr(v, "$$ER: E100") > 0 Then
.Rows(r).Delete
End If
Next r

' Đổi tên cột CURRENCY → ID


.Cells(1, currCol).Value = "ID"

' Tạo ID từ CODE (lấy phần trước dấu ngoặc)


lastRow = .Cells(.Rows.Count, codeCol).End(xlUp).Row
For r = 2 To lastRow
v = .Cells(r, codeCol).Value & ""
pos = InStr(v, "(")
If pos > 0 Then
.Cells(r, currCol).Value = Left(v, pos - 1)
Else
.Cells(r, currCol).Value = v
End If
Next r
End With
NextSheet:
Next ws

Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

You might also like