Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default need help with formatting data collected from database...


Hi,
I couldn't get the search tool to work on this forum, so hopefully I'm
not repeating a previously asked question...
This is probably an easy solution to solve, but I have had very limited
experience working with VBA and excel macros.
At the moment, I have a macro that gathers data from a database and
then displays it on a worksheet. The macro also formats a border around
the data. At the moment, the code looks a bit like this:

With Range("A4:AB1000")
With .Borders(xlEdgeLeft)
..LineStyle = xlContinuous
..Weight = xlMedium
..ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
..LineStyle = xlContinuous
..Weight = xlMedium
..ColorIndex = xlAutomatic
End With
End With

and so on for some more border types. What I would like to do, would be
rather than have the line "With Range("A4:AB1000"), I'd like to replace
"AB1000" with a variable that accounts for the amount of rows of data
that is pulled out of the database, as the database is constantly
changing, and I suspect I will need much more than 1000 rows to be
formatted in the future.

Hope someone can help !
Thanks,
Mandy


--
mandles1
------------------------------------------------------------------------
mandles1's Profile: http://www.excelforum.com/member.php...o&userid=29754
View this thread: http://www.excelforum.com/showthread...hreadid=494761

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default need help with formatting data collected from database...

There are a few way to do this. Try the sample spreadsheet ref # 69 here
http://www.xl-logic.com/pages/vba.html

Alternatively, create a dynamic named range and select this. If you decide
to use this, search for "dynamic named range" on the web for examples.

--
Steve


"mandles1" wrote in
message ...

Hi,
I couldn't get the search tool to work on this forum, so hopefully I'm
not repeating a previously asked question...
This is probably an easy solution to solve, but I have had very limited
experience working with VBA and excel macros.
At the moment, I have a macro that gathers data from a database and
then displays it on a worksheet. The macro also formats a border around
the data. At the moment, the code looks a bit like this:

With Range("A4:AB1000")
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
End With

and so on for some more border types. What I would like to do, would be
rather than have the line "With Range("A4:AB1000"), I'd like to replace
"AB1000" with a variable that accounts for the amount of rows of data
that is pulled out of the database, as the database is constantly
changing, and I suspect I will need much more than 1000 rows to be
formatted in the future.

Hope someone can help !
Thanks,
Mandy


--
mandles1
------------------------------------------------------------------------
mandles1's Profile:
http://www.excelforum.com/member.php...o&userid=29754
View this thread: http://www.excelforum.com/showthread...hreadid=494761



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default need help with formatting data collected from database...

You could try

Range("A4").CurrentRegion

if your block of data is contiguous and has empty rows/columns surrounding
it. Also you might think about being more explicit when you define the
range:

Eg:
ActiveSheet.Range("A4").CurrentRegion

This will avoid any future confusion as your code mutates and you add new
functionality...
Tim.

--
Tim Williams
Palo Alto, CA


"mandles1" wrote in
message ...

Hi,
I couldn't get the search tool to work on this forum, so hopefully I'm
not repeating a previously asked question...
This is probably an easy solution to solve, but I have had very limited
experience working with VBA and excel macros.
At the moment, I have a macro that gathers data from a database and
then displays it on a worksheet. The macro also formats a border around
the data. At the moment, the code looks a bit like this:

With Range("A4:AB1000")
With .Borders(xlEdgeLeft)
LineStyle = xlContinuous
Weight = xlMedium
ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
LineStyle = xlContinuous
Weight = xlMedium
ColorIndex = xlAutomatic
End With
End With

and so on for some more border types. What I would like to do, would be
rather than have the line "With Range("A4:AB1000"), I'd like to replace
"AB1000" with a variable that accounts for the amount of rows of data
that is pulled out of the database, as the database is constantly
changing, and I suspect I will need much more than 1000 rows to be
formatted in the future.

Hope someone can help !
Thanks,
Mandy


--
mandles1
------------------------------------------------------------------------
mandles1's Profile:

http://www.excelforum.com/member.php...o&userid=29754
View this thread: http://www.excelforum.com/showthread...hreadid=494761



Reply
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
Saving collected data? Rebecca[_4_] Excel Discussion (Misc queries) 1 March 18th 10 04:19 PM
creating data points within collected data Excel Data Excel Worksheet Functions 1 November 30th 09 05:42 PM
database query not showing foxpro database How I import data mangat New Users to Excel 1 June 24th 07 03:31 PM
Clipboard Item not collected Snikermom Excel Discussion (Misc queries) 0 October 10th 06 07:40 PM
Can I make a list, on one summary sheet, of data collected from ma anamcara Excel Worksheet Functions 3 December 15th 05 11:04 AM


All times are GMT +1. The time now is 09:58 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"