Access to Excel Using CurrentRegion

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,733
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
Platform
  1. Windows
How can I use the CurrentRegion command in Excel but from Access.

I am exporting multiple queries from Access to a single book and I have been asked to set a format to each sheet but they have different ranges so the use fo currentregion would be very useful.
 
Hi F

I have tried the debug.print and it stated I need a with statement.

I considered creating another module sheet to at least try and do some formatting on each sheet and ended up with a result I think I can work with. I will have to look to rethink this through over the weekend. I have a week or so to try and implement a number of reports into Excel where I have to format each sheet and also then do some other things, but for know if the below is working then I can move on.

I hope you have a lovely weekend.

Function baorder1()
Dim xlapp As Excel.Application
Dim wssheet As Worksheet
Set xlapp = CreateObject("Excel.Application")
With xlapp
.Visible = True
.Workbooks.Open CurrentProject.Path & "\" & "ExportResults QryExcel1.xls"
End With
Dim I As Long
For I = 1 To xlapp.Worksheets.Count
xlapp.Worksheets(I).Select
xlapp.Range("b7").Select
xlapp.Selection.CurrentRegion.Select
With xlapp.Selection

.Borders.LineStyle = xlContinuous
End With

Next I
xlapp.Worksheets(1).Select
End Function
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
if you post the code where you use the debug.print I can understand what is happening

the debug.print error will be minor

if the debug.print works (or not), it demonstrates that you can use .currentregion (or not)

if you don't use the .select, it would help the original code. I think the errors are due to the selecting & that you are nearly there

when posting code, please use the code tags

though, it sounds like you are OK for now...?
 
Upvote 0
Yes I should use the code tags, I sometimes just get swept away with trying to sort an issue.

I have now completed this task as I then used the xlApp at the end of my long amount of code to select the first sheet in the book and I am now formatting what I need to.

So happy bunny (well for today....)
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,762
Members
449,048
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top