PDA

View Full Version : Checking format of a selected Range



Mr.KK
08-10-2018, 05:32 AM
Hi I need to check the formating (left allignement of each cell) in a specific range in a sheet. the cell range cannot be hard coded as it varies from document to document. so i used the below code. The problem is, this works when this particular sheet is selected by default. My aim is to have a tool, which will open a file from a path, select the range as given below in particular sheet, and if the formating is not proper, write a remark in the tool's remark area which is a different workbook than the opened workbook. can anyone help with this? I have got the code to open files from the folder. I get the rng properly while compiling, but its not giving the remarks.


'To Scan through the cells in a range and check left alignment
With Sheets("Document Information").Range("A1:J55")
Set rng = .Find(What:="Revision History / ?????? ? ????????? ?????????:", _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

End With
rng.Offset(2, 0).Resize(2, 10).Select
With Selection
For Rw = 1 To 2
For C = 1 To 10
If Selection.Cells(Rw, C).HorizontalAlignment <> xlLeft Then
Sheets("Sheet2").Cells(1, 4).Value = "allign NOT OK"
End If
Next C
Next Rw
End With