Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-05-2018, 03:31 PM
p45cal's Avatar
p45cal p45cal is offline creating a named row for dynamic addressing Windows 10 creating a named row for dynamic addressing Office 2016
Expert
 
Join Date: Apr 2014
Posts: 956
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

First, the likes of:
Mid(ActiveCell.Address, 4, 4)
can be more reliably written as:
Activecell.row
but you don't need it.

Let's say that column J on your sheet has the header "hdr7" for the table.
Then likes of:
Code:
Sheets("Address Label").Range("C5") = Range("j" & Mid(ActiveCell.Address, 4, 4))
can be:
Code:
Sheets("Address Label").Range("C5") = intersect(activecell.EntireRow,activecell.ListObject.ListColumns("hdr7").Range)
and since you'll be using activecell.ListObject on multiple lines you can make things easier with the likes of:
Code:
    Set tbl = ActiveCell.ListObject
        Sheets("Payment Advice").Range("B3") = Date
        Sheets("Address Label").Range("C5") = Intersect(ActiveCell.EntireRow, tbl.ListColumns("hdr1").Range)
        Sheets("Payment Advice").Range("B4") = Intersect(ActiveCell.EntireRow, tbl.ListColumns("hdr2").Range)
        Sheets("Payment Advice").Range("B5") = Intersect(ActiveCell.EntireRow, tbl.ListColumns("hdr3").Range)
        Sheets("Payment Advice").Range("B6") = Intersect(ActiveCell.EntireRow, tbl.ListColumns("hdr4").Range)
where I've invented imaginary header names hdr1, hdr2 etc.


There'll many ways, this one not necessarily the slickest.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating a named row for dynamic addressing Creating Dynamic Ranking Tables ssol2016 Excel 1 10-27-2016 08:47 AM
creating a code to create dynamic text in word ah8471 Word VBA 1 12-29-2015 10:52 PM
creating a named row for dynamic addressing Creating a dynamic summary sheet FenelonPaul Excel 5 09-23-2015 07:11 AM
creating a named row for dynamic addressing Help Creating A Dynamic Footer Mikemo Word 3 02-05-2013 11:58 AM
Dynamic Named Ranges using text hannu Excel 0 06-22-2010 04:42 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:02 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft