Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Selecting and copying a dynamic range of cells

I need to select and copy a row of headers in a spreadsheet starting from A1.
The number of columns with headers is not always the same. I would like to
paste them alongside the original headers but offset by one column.

Thank you for you help,

Esther
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Selecting and copying a dynamic range of cells

I am not sure if this is exactly what you want... It is a little odd but it
is exactly what you asked for...

Public Sub CopyHeaders()
Dim rngToCopy As Range
Dim wks As Worksheet

Set wks = ActiveSheet
Set rngToCopy = Range(wks.Range("A1"), wks.Range("IV1").End(xlToLeft))

rngToCopy.Copy wks.Range("B1")

End Sub

If all you are trying to do is to shift your headings one cell to the left
then it is a lot easier than Copying and Pasting. Just insert a cell similar
to this

Public Sub ShiftHeaders()
ActiveSheet.Range("A1").Insert xlToRight
End Sub
--
HTH...

Jim Thomlinson


"EstherJ" wrote:

I need to select and copy a row of headers in a spreadsheet starting from A1.
The number of columns with headers is not always the same. I would like to
paste them alongside the original headers but offset by one column.

Thank you for you help,

Esther

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Selecting and copying a dynamic range of cells

Esther,

Sub CopyHeaders()
Range("A1", Range("A1").End(xlToRight)).Copy _
Range("A1").End(xlToRight)(1, 3)
End Sub

That said, it is a BAD idea to use more than one data table with the same headers. Better by far to
add another column into your existing table to enter a value that would differentiate the new from
the old, and then your data is better formatted for filtering, use in pivot tables, etc.

HTH,
Bernie
MS Excel MVP


"EstherJ" wrote in message
...
I need to select and copy a row of headers in a spreadsheet starting from A1.
The number of columns with headers is not always the same. I would like to
paste them alongside the original headers but offset by one column.

Thank you for you help,

Esther



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
Selecting and copying fill colored cells Vicki Excel Discussion (Misc queries) 1 December 5th 08 10:06 AM
Range selecting cells Alec H Excel Discussion (Misc queries) 2 March 14th 06 01:36 PM
selecting a range of cells Grandma Barb[_3_] Excel Programming 1 March 5th 05 02:52 AM
VBA: copying and inserting a dynamic range JP[_10_] Excel Programming 2 June 1st 04 10:29 PM
Selecting & Copying a Changing Range DNewton[_3_] Excel Programming 2 May 3rd 04 03:44 PM


All times are GMT +1. The time now is 04:51 AM.

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"