ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hardcode (https://www.excelbanter.com/excel-programming/408134-hardcode.html)

Steve[_4_]

Hardcode
 
Hello. Given the following code, how can I have the result of the
formulas hardcoded? I tried simply adding .value at the end of each,
but that did not work! Thanks!

LastRow = Worksheets("Log").Cells(Cells.Rows.Count, "A").End(xlUp).Row

With Worksheets("Log")
.Range("A" & LastRow + 1).Formula = "='Extended Terms'!C8"
.Range("B" & LastRow + 1).Formula = "='Extended Terms'!C6"
.Range("C" & LastRow + 1).Formula = "='Extended Terms'!C5"
.Range("D" & LastRow + 1).Formula = "='Extended Terms'!C7"
.Range("E" & LastRow + 1).Formula = "='Extended Terms'!C17"
.Range("F" & LastRow + 1).Formula = "='Extended Terms'!C23"
.Range("G" & LastRow + 1).Formula = "='Extended Terms'!C11"
.Range("H" & LastRow + 1).Formula = "='Extended Terms'!C77"
.Range("I" & LastRow + 1).Formula = "='Extended Terms'!C12"
.Range("J" & LastRow + 1).Formula = "='Extended Terms'!I8"
.Range("K" & LastRow + 1).Formula = "='Extended Terms'!I7"
End With

Don Guillett

Hardcode
 
Please give YOUR definition of "hardcoded" If you mean you want to leave the
values instead of the formulas then
either change to values when finished

..Range(cells("A",LastRow + 1),cells("k",lastrow+1)).value = _
..Range(cells("A",LastRow + 1),cells("k",lastrow+1)).value

or this idea

..Range("A" & LastRow + 1).value= sheets("Extended Terms").range("C8")



--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Steve" wrote in message
...
Hello. Given the following code, how can I have the result of the
formulas hardcoded? I tried simply adding .value at the end of each,
but that did not work! Thanks!

LastRow = Worksheets("Log").Cells(Cells.Rows.Count, "A").End(xlUp).Row

With Worksheets("Log")
.Range("A" & LastRow + 1).Formula = "='Extended Terms'!C8"
.Range("B" & LastRow + 1).Formula = "='Extended Terms'!C6"
.Range("C" & LastRow + 1).Formula = "='Extended Terms'!C5"
.Range("D" & LastRow + 1).Formula = "='Extended Terms'!C7"
.Range("E" & LastRow + 1).Formula = "='Extended Terms'!C17"
.Range("F" & LastRow + 1).Formula = "='Extended Terms'!C23"
.Range("G" & LastRow + 1).Formula = "='Extended Terms'!C11"
.Range("H" & LastRow + 1).Formula = "='Extended Terms'!C77"
.Range("I" & LastRow + 1).Formula = "='Extended Terms'!C12"
.Range("J" & LastRow + 1).Formula = "='Extended Terms'!I8"
.Range("K" & LastRow + 1).Formula = "='Extended Terms'!I7"
End With



Dave Peterson

Hardcode
 
Instead of lines like this:

..Range("A" & LastRow + 1).Formula = "='Extended Terms'!C8"

You could use:
..Range("A" & LastRow + 1).value = worksheets("extended terms").range("C8").value

Depending on what's in those cells, you may want:

with .Range("A" & LastRow + 1)
.numberformat = worksheets("extended terms").range("C8").numberformat
.value = worksheets("extended terms").range("C8").value
end with



Steve wrote:

Hello. Given the following code, how can I have the result of the
formulas hardcoded? I tried simply adding .value at the end of each,
but that did not work! Thanks!

LastRow = Worksheets("Log").Cells(Cells.Rows.Count, "A").End(xlUp).Row

With Worksheets("Log")
.Range("A" & LastRow + 1).Formula = "='Extended Terms'!C8"
.Range("B" & LastRow + 1).Formula = "='Extended Terms'!C6"
.Range("C" & LastRow + 1).Formula = "='Extended Terms'!C5"
.Range("D" & LastRow + 1).Formula = "='Extended Terms'!C7"
.Range("E" & LastRow + 1).Formula = "='Extended Terms'!C17"
.Range("F" & LastRow + 1).Formula = "='Extended Terms'!C23"
.Range("G" & LastRow + 1).Formula = "='Extended Terms'!C11"
.Range("H" & LastRow + 1).Formula = "='Extended Terms'!C77"
.Range("I" & LastRow + 1).Formula = "='Extended Terms'!C12"
.Range("J" & LastRow + 1).Formula = "='Extended Terms'!I8"
.Range("K" & LastRow + 1).Formula = "='Extended Terms'!I7"
End With


--

Dave Peterson


All times are GMT +1. The time now is 11:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com