galbatrox9
New Member
- Joined
- Aug 30, 2017
- Messages
- 23
Hi,
I have an excel workbook which has has a macro written for an older format of file we maintained , can the cell references be changed to match my new format of file?
This is the code :-
There are two sheets involved in the code. This is sheet "Input"
This is the sheet "Name"
Now in the new format of my file, the columns for the sheet "Input" have changed to the below (Columns needed F,G,H,I and P):
I cant understand the code written by my team. Can someone fix this please?
I have an excel workbook which has has a macro written for an older format of file we maintained , can the cell references be changed to match my new format of file?
This is the code :-
Code:
Sub testextract()Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim i, j, k, l, flg, lt_rw1, lt_rw2 As Integer
Dim t1, t2, t3 As String
ThisWorkbook.Sheets("input").Activate
lt_rw1 = ThisWorkbook.Sheets("Input").Range("A65536").End(xlUp).Row
lt_rw2 = ThisWorkbook.Sheets("Name").Range("A65536").End(xlUp).Row
If (lt_rw1 > 1) Then
For i = 2 To lt_rw1
For l = 1 To 4
If Cells(i, l).Value = "" Then
Exit For
Else
t1 = UCase(Cells(i, l).Value)
For j = 2 To lt_rw2
For k = 2 To 4
If (ThisWorkbook.Sheets("Name").Cells(j, k).Value = "") Then
flg = 0
Exit For
Else
t2 = UCase(ThisWorkbook.Sheets("Name").Cells(j, k).Value)
t3 = UCase(ThisWorkbook.Sheets("Name").Cells(j, 1).Value)
If InStr(1, t1, t2) > 0 Then
Cells(i, 5).Value = t3
flg = 1
Exit For
Else
flg = 0
Cells(i, 5).Value = "Not Available"
End If
End If
Next k
If (flg = 1) Then
Exit For
End If
Next j
End If
If (flg = 1) Then
Exit For
End If
Next l
Next i
End If
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Name Extracted Successfully..!", vbOKOnly + vbInformation, "Issuer Extracted"
End Sub
There are two sheets involved in the code. This is sheet "Input"
This is the sheet "Name"
Now in the new format of my file, the columns for the sheet "Input" have changed to the below (Columns needed F,G,H,I and P):
I cant understand the code written by my team. Can someone fix this please?