ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create Table with the range of selected cells (https://www.excelbanter.com/excel-programming/358261-create-table-range-selected-cells.html)

antik888

Create Table with the range of selected cells
 
Hi guys!

I need some help with setting up vba that would insert a table with headers, with the name of current time and most importantly range of the selected cells.

Thanks for any help.
Anton.

Gord Dibben[_2_]

Create Table with the range of selected cells
 
Have you tried the macro recorder?

If you run into any issues, post back with the code and expected
results.


Gord


On Sun, 29 Jan 2012 18:55:29 +0000, antik888
wrote:


Hi guys!

I need some help with setting up vba that would insert a table with
headers, with the name of current time and most importantly range of the
selected cells.

Thanks for any help.
Anton.


Scott Spence

Create Table with the range of selected cells
 
Return the range of selected cells:

Selection.Address

Scott Spence

Create Table with the range of selected cells
 
Return the range of selected cells:

Selection.Address

Will return a string with the selected area address

antik888

Quote:

Originally Posted by antik888 (Post 1263271)
Hi guys!

I need some help with setting up vba that would insert a table with headers, with the name of current time and most importantly range of the selected cells.

Thanks for any help.
Anton.


The code looks like this

Code:

ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1:A2"), , xlYes).Name = _
        "Table3"

But I need to change the name of the table to current date or time. How would it look like?

Scott Spence

Create Table with the range of selected cells
 
ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1:A2"), , xlYes).Name = _
Format(Now(),"yyyy/mm/dd")

Scott Spence

Create Table with the range of selected cells
 
Like this:

ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1:A2"), , xlYes).Name = _
Format(Now(),"yyy/mm/dd")

Scott Spence

Create Table with the range of selected cells
 
Like this:

ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1:A2"), , xlYes).Name = _
Format(Now(),"yyy/mm/dd")


All times are GMT +1. The time now is 06:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com