Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro that uses a value as the range

Hi,

I am wondering if anyone could shed some light on how i can program a value
say in A1 that is constantly changing, and use the value as the destination
to paste information on another sheet.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Macro that uses a value as the range

This sets c as the object variable for a value in sheet 2 that equals the
value in A1 of sheet 1. It then copies someRange designated by the user to a
destination that is two cells to the right of the cell with the found value
of c.

Sub findValueA1()
Dim c As Range
Set someRange = Sheets(1).Range("C5") '<<<Change to need
Set c = Sheets(2).Cells.Find(Sheets(1).Range("A1").Value _
LookIn:=xlValues) '<<<add additional parameters in needed.
If Not c Is Nothing Then
Sheets(1).Range(someRange).Copy Sheets(2) _
c.Offset(0, 2)
End If
End Sub




"jpbat1591" wrote:

Hi,

I am wondering if anyone could shed some light on how i can program a value
say in A1 that is constantly changing, and use the value as the destination
to paste information on another sheet.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Macro that uses a value as the range

Say we want to put a message in Sheet2
Sheet1, cell A1 contains Z100 (the destination address)
Sheet2, cell A2 contains the message:

"Klaatu barada nikto"


Here is a sample macro:

Sub gort()
Set a1 = Range("A1")
Set a2 = Range("A2")
destin = a1.Value
a2.Copy Sheets("Sheet2").Range(destin)
End Sub


--
Gary''s Student - gsnu200798


"jpbat1591" wrote:

Hi,

I am wondering if anyone could shed some light on how i can program a value
say in A1 that is constantly changing, and use the value as the destination
to paste information on another sheet.

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 to select range from active cell range name string aelbob Excel Programming 2 July 14th 08 09:19 PM
Macro deletes row in range, macro then skips the row moved up steven.holloway Excel Discussion (Misc queries) 8 June 11th 08 11:40 AM
Macro to copy a specified range to a variable range SWT Excel Programming 4 October 21st 05 08:24 PM
Macro won't execute when "For Each 'range' in 'range'" is added Bill Dika Excel Programming 1 July 12th 04 07:33 PM
Macro to input formula in range based on another range Peter Atherton Excel Programming 0 October 9th 03 12:47 AM


All times are GMT +1. The time now is 11:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"