Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-02-2023, 01:01 AM
Holytuna Holytuna is offline After macro is created Windows Vista After macro is created Office 2021
Novice
After macro is created
 
Join Date: Jan 2023
Posts: 2
Holytuna is on a distinguished road
Default After macro is created


So I pull data from a data base this information may change
My issue is control a then creating a table may change from report to report so when I first do the macro it may have only 100 rows and when I run the macro for another report it may have 150 rows. When running it it will only catch when I did the first report. Is there a way to automatically catch all rows regardless if it has 100 rows or 500 rows of data?
Reply With Quote
  #2  
Old 01-02-2023, 01:20 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline After macro is created Windows 10 After macro is created Office 2021
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,779
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Hi
make your range an Excel Table and correct your Macro accordingly
(BTW there is a VBA dedicated subforum on this forum)
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #3  
Old 01-06-2023, 04:01 PM
spillerbd spillerbd is offline After macro is created Windows 10 After macro is created Office 2021
Competent Performer
 
Join Date: Jan 2016
Posts: 130
spillerbd is on a distinguished road
Default

You can also use CurrentRegion, which is like pressing CTRL+* in a range, and may be better depending on the source of the data/workbook. TABLES are generally better.
Code:
MyTableasRange = MyWorksheet.Range("A1").CurrentRegion
Where the variable MyTableRange is DIM as a RANGE
and MyWorkSheet is DIM as a Worksheet and defined to the desired worksheet where the table resides.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
After macro is created Can a Macro be run such that by which an Excel table (one is created by ctrl+t) be “Pasted Link” to soroush.kalantari Word VBA 3 09-21-2021 11:48 PM
How to remove space between header and first bullet in Outlook email created by Excel macro kevinbradley57 Excel Programming 1 03-27-2019 08:39 PM
Forms created in Word Johnmcl Word 7 11-25-2015 07:01 PM
After macro is created Pre Created Form help SRKS72 Word 4 08-30-2014 03:57 PM
mtg/appt. created - enter into SQL db also manared Outlook 0 02-07-2011 11:04 AM

Other Forums: Access Forums

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


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