greatparthi
New Member
- Joined
- Feb 14, 2016
- Messages
- 2
Before I begin, I should tell you all that I am a complete noob to excel and VBA macro.
I am trying to compare two excel sheet data by using EXACT formula. sometimes the data ranges to 50 columns and 10000+ rows, So I am using a VBA macro to define the range and applying the formula. perhaps the following code will explain better,
I was manually inputting the range values to insert formula and apply the formatting. Now I would like to avail some help on applying the formula dynamically based on the Sheet1 cell ranges.
i.e., if Sheet1 contains data till A1:AU5000, then in Sheet 3 When I run this VBA I want formula to be applied on that range.
Sub FormulaInsertion()
'macro to insert formula
Range("G1:L101").Formula = "=EXACT(Sheet1!A1, Sheet2!A1)"
Call FormattingValues
End Sub
Sub FormattingValues()
'
' Formatting Macro
'
Range("G1:L101").Select
Selection.FormatConditions.Add Type:=xlTextString, String:="FALSE", _
TextOperator:=xlContains
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlTextString, String:="TRUE", _
TextOperator:=xlContains
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
End Sub
I am trying to compare two excel sheet data by using EXACT formula. sometimes the data ranges to 50 columns and 10000+ rows, So I am using a VBA macro to define the range and applying the formula. perhaps the following code will explain better,
I was manually inputting the range values to insert formula and apply the formatting. Now I would like to avail some help on applying the formula dynamically based on the Sheet1 cell ranges.
i.e., if Sheet1 contains data till A1:AU5000, then in Sheet 3 When I run this VBA I want formula to be applied on that range.
Sub FormulaInsertion()
'macro to insert formula
Range("G1:L101").Formula = "=EXACT(Sheet1!A1, Sheet2!A1)"
Call FormattingValues
End Sub
Sub FormattingValues()
'
' Formatting Macro
'
Range("G1:L101").Select
Selection.FormatConditions.Add Type:=xlTextString, String:="FALSE", _
TextOperator:=xlContains
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlTextString, String:="TRUE", _
TextOperator:=xlContains
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
End Sub