LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ed Ed is offline
external usenet poster
 
Posts: 279
Default Using "Names" in VBA codes

Hello I would like to know in which way I can have values as "Names" or
something like that to use them in a code... to replace for example in the
code below:

Worksheets("Budget").Range("G24")

With something like a Name, so if I happen to add or delete rows above row G
the reference is still valid, and it doesn't just take G24 regardless of what
it contains.

Sub Data()
Dim LastRow As Long
With ActiveSheet
LastRow = .Range("B1").Value
Range("b19:f" & LastRow).FillDown

Range("c" & LastRow + 2) = Worksheets("Budget").Range("G24")
Range("f" & LastRow + 2) = Worksheets("Budget").Range("H24")

Range("c" & LastRow + 3) = Worksheets("Budget").Range("G25")
Range("f" & LastRow + 3) = Worksheets("Budget").Range("H25")

Range("C" & LastRow + 5) = "TOTAL"
Range("C" & LastRow + 5).Select
Selection.Font.Bold = True

Range("f" & LastRow + 5) = Worksheets("Budget").Range("H27")
Range("f" & LastRow + 5).Select
Selection.Font.Bold = True

End With
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel and zip codes dm Excel Discussion (Misc queries) 10 September 12th 06 07:34 PM
Sorting by 5 digit & 5 digit plus 4 zip codes D Marie Excel Worksheet Functions 1 August 22nd 06 05:17 PM
codes, codes, codes... jatman Excel Discussion (Misc queries) 2 August 20th 06 07:30 AM
printing zip codes Farmom Excel Discussion (Misc queries) 4 August 10th 06 03:14 AM
I have two columns (A) and (G) that have like product codes however [email protected] Excel Worksheet Functions 1 August 4th 06 08:19 PM


All times are GMT +1. The time now is 02:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"