Please find the attached file.I have tried this code more than 50 times, now it is working correctly, thing you should note that this attachment contains a sheet rough which need to be there if you wish You can remove that after doing your work.
This code will highlight cell in yellow which is formatted in currency format, if that suits your need, comment this line after checking
y.Interior.Color = vbYellow so that it will not mark yellow color on formatted cells.(Yellow color is just for check for right cells done)
Sub T()
With Application: .Calculation = xlCalculationManual: .ScreenUpdating = False: .DisplayAlerts = False
End With
On Error Resume Next
Dim Intro As Worksheet
Dim data As Worksheet
Dim rough As Worksheet
Set Intro = Sheets("Introduction")
Set data = Sheets("Data_Entry")
Set rough = Worksheets("Rough")
Range("D4").Value = Application.WorksheetFunction.VLookup(Intro.Range("B3").Value, data.Range("A:B"), 2, 0)
Range("D5").Value = Application.WorksheetFunction.VLookup(Intro.Range("B3").Value, data.Range("A:C"), 3, 0)
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "Introduction" And ws.Name <> "Data_Entry" And ws.Name <> "Rough" Then
ws.Select
For Each y In ws.UsedRange
Debug.Print y.Address
If IsNumeric(y) And y.Value <> "" Then
rough.Range("A1").Value = "=cell(""format""," & "'" & ws.Name & "'!" & ws.Range(y.Address).Address & ")"
If rough.Range("A1").Value = "C2" Or rough.Range("A1") = ",2" Then
y.NumberFormat = Intro.Range("D5").Value
y.Interior.Color = vbYellow
rough.Range("A1").Value = ""
End If
End If
Next
End If
Next
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
Bookmarks