I am trying to read the data in the last cell of a column. The value of "X" should be the value of this last cell. I then want "X" to be compared to the number of rows and if the number of rows is less than "X", perform my macro "AddProj". Once "X" and Column A are the same value, nothing else is to be done.
For some reason, it is not working. This code is on the worksheet where I want the comparison to be made. Please see my code below:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">PrivateSub Worksheet_Calculate()
X = LastCell
If Sheet5.Range("A"& Rows.Count).Value < Sheet5.Range("X").Value Then
Sheet5.Range("X").Value =Me.Range("A"& Rows.Count).Value
AddProj
EndIf
EndSub
Sub LastCell()
Range("A1").End(xlDown).Select
EndSub</code>The "AddProj" is a module that is referenced in the code above:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Sub AddProj()
Sheet1.Range("Master").Copy Sheet1.Range("C"& Rows.Count).End(xlUp).Offset(1)
EndSub</code>Thanks in advance.
For some reason, it is not working. This code is on the worksheet where I want the comparison to be made. Please see my code below:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">PrivateSub Worksheet_Calculate()
X = LastCell
If Sheet5.Range("A"& Rows.Count).Value < Sheet5.Range("X").Value Then
Sheet5.Range("X").Value =Me.Range("A"& Rows.Count).Value
AddProj
EndIf
EndSub
Sub LastCell()
Range("A1").End(xlDown).Select
EndSub</code>The "AddProj" is a module that is referenced in the code above:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Sub AddProj()
Sheet1.Range("Master").Copy Sheet1.Range("C"& Rows.Count).End(xlUp).Offset(1)
EndSub</code>Thanks in advance.