Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Referencing Cell Location

I have imported data from a .txt file. The data is all located in column A
and already in a proper format. I need the macro to do the following:

Read each cell... when it finds the date, the cell below should be set as
the reference cell. The value is not important. Copy specified ranges of
cells and pastespecial - transpose next to the reference cell. Below is what
I have so far. This works, but the problem lies with the absolute reference
to range B3 & E4. I will need to run this on 30,000 lines referencing offset
cells from a new reference point each time a date is found.

If I could set the cell below a date equal to the cell location and then
activate the cell for and each paste, I think that would work, but I can't
figure it out.

Brand new to VBA.

Thanks,
Adam

Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(14, 0)).copy
Range("b3").Select
Selection.PasteSpecial Paste:=xlAll, Transpose:=True

Range(ActiveCell.Offset(15, 0), ActiveCell.Offset(25, 0).Select
Selection.copy
Range("e4").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Referencing Cell Location

Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(14, 0)).copy
ActiveCell.offset(2,1)Select <added offset
Selection.PasteSpecial Paste:=xlAll, Transpose:=True

Range(ActiveCell.Offset(15, 0), ActiveCell.Offset(25, 0).Select
Selection.copy
ActiveCell.offset(3,4).Select <added offset
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True

"watchtower" wrote:

I have imported data from a .txt file. The data is all located in column A
and already in a proper format. I need the macro to do the following:

Read each cell... when it finds the date, the cell below should be set as
the reference cell. The value is not important. Copy specified ranges of
cells and pastespecial - transpose next to the reference cell. Below is what
I have so far. This works, but the problem lies with the absolute reference
to range B3 & E4. I will need to run this on 30,000 lines referencing offset
cells from a new reference point each time a date is found.

If I could set the cell below a date equal to the cell location and then
activate the cell for and each paste, I think that would work, but I can't
figure it out.

Brand new to VBA.

Thanks,
Adam

Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(14, 0)).copy
Range("b3").Select
Selection.PasteSpecial Paste:=xlAll, Transpose:=True

Range(ActiveCell.Offset(15, 0), ActiveCell.Offset(25, 0).Select
Selection.copy
Range("e4").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Referencing Cell Location

Thanks, Joel.

The problem with that is the active cell is no longer the original reference
below the date cell. After the paste, you have an active range and must
select the cell again.

Adam

"Joel" wrote:

Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(14, 0)).copy
ActiveCell.offset(2,1)Select <added offset
Selection.PasteSpecial Paste:=xlAll, Transpose:=True

Range(ActiveCell.Offset(15, 0), ActiveCell.Offset(25, 0).Select
Selection.copy
ActiveCell.offset(3,4).Select <added offset
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True

"watchtower" wrote:

I have imported data from a .txt file. The data is all located in column A
and already in a proper format. I need the macro to do the following:

Read each cell... when it finds the date, the cell below should be set as
the reference cell. The value is not important. Copy specified ranges of
cells and pastespecial - transpose next to the reference cell. Below is what
I have so far. This works, but the problem lies with the absolute reference
to range B3 & E4. I will need to run this on 30,000 lines referencing offset
cells from a new reference point each time a date is found.

If I could set the cell below a date equal to the cell location and then
activate the cell for and each paste, I think that would work, but I can't
figure it out.

Brand new to VBA.

Thanks,
Adam

Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(14, 0)).copy
Range("b3").Select
Selection.PasteSpecial Paste:=xlAll, Transpose:=True

Range(ActiveCell.Offset(15, 0), ActiveCell.Offset(25, 0).Select
Selection.copy
Range("e4").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Referencing Cell Location

You can set a variable to the activecell before the operation, then reference
this cell latter in the macro.

set Oldcell = activecell
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(14, 0)).copy
OldCell.offset(2,1)Select <added offset
Selection.PasteSpecial Paste:=xlAll, Transpose:=True

Range(OldCell.Offset(15, 0), ActiveCell.Offset(25, 0).Select
Selection.copy
OldCell.offset(3,4).Select <added offset
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True



"watchtower" wrote:

Thanks, Joel.

The problem with that is the active cell is no longer the original reference
below the date cell. After the paste, you have an active range and must
select the cell again.

Adam

"Joel" wrote:

Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(14, 0)).copy
ActiveCell.offset(2,1)Select <added offset
Selection.PasteSpecial Paste:=xlAll, Transpose:=True

Range(ActiveCell.Offset(15, 0), ActiveCell.Offset(25, 0).Select
Selection.copy
ActiveCell.offset(3,4).Select <added offset
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True

"watchtower" wrote:

I have imported data from a .txt file. The data is all located in column A
and already in a proper format. I need the macro to do the following:

Read each cell... when it finds the date, the cell below should be set as
the reference cell. The value is not important. Copy specified ranges of
cells and pastespecial - transpose next to the reference cell. Below is what
I have so far. This works, but the problem lies with the absolute reference
to range B3 & E4. I will need to run this on 30,000 lines referencing offset
cells from a new reference point each time a date is found.

If I could set the cell below a date equal to the cell location and then
activate the cell for and each paste, I think that would work, but I can't
figure it out.

Brand new to VBA.

Thanks,
Adam

Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(14, 0)).copy
Range("b3").Select
Selection.PasteSpecial Paste:=xlAll, Transpose:=True

Range(ActiveCell.Offset(15, 0), ActiveCell.Offset(25, 0).Select
Selection.copy
Range("e4").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True

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
Macro - save to current location vs excel default location leezard Excel Discussion (Misc queries) 0 October 28th 08 03:04 PM
How to shift the cell based on the location of other cell? Paul Excel Programming 3 February 27th 06 07:08 PM
automatic offset cell location when there is a value in a selected cell. kuansheng Excel Worksheet Functions 0 February 23rd 06 01:40 AM
Mouse Location, Movement and Spreadsheet Location TCook Excel Programming 3 October 3rd 05 10:23 PM
Populating one cell with the physcial location of a different cell Linking to specific cells in pivot table Excel Programming 2 May 18th 05 11:57 AM


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