Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to replace cells by (predefined) ranges

Hello,
I have defined several ranges with formula's in sheet2 eg:
range1=A1:D5 (5rows),
range2=A10:D20 (10rows),
range3=A30:D37 (7rows)

In sheet1:column A I have cell values
range2
range2
range1
range3,
etc

How can I insert the matching range defined in sheet2 into sheet1,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to replace cells by (predefined) ranges

I wrote next Sub,

Sub InsertRange()

Dim cellToReturnTo As Range
Set cellToReturnTo = ActiveCell
Dim sSearchValue As String
sSearchValue = ActiveCell.Text
Cells.Find(What:=sSearchValue, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Sheets("MacroData").Select
Range(sSearchValue).Select
Selection.Copy
Application.GoTo cellToReturnTo
Selection.Insert Shift:=xlDown
End Sub

wich works fine if the cell values in sheet 1 are "plain" text,
except they are Excel formula's,

I think I have to replace "sSearchValue = ActiveCell.Text"
into something else BUt I don't know what

"firsttimer" wrote:

Hello,
I have defined several ranges with formula's in sheet2 eg:
range1=A1:D5 (5rows),
range2=A10:D20 (10rows),
range3=A30:D37 (7rows)

In sheet1:column A I have cell values
range2
range2
range1
range3,
etc

How can I insert the matching range defined in sheet2 into sheet1,

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
Selectively replace cells based on two ranges of criteria - nestedIF() statements? MCSmarties Excel Discussion (Misc queries) 1 May 21st 08 09:49 PM
sum quarters to years; predefined shift of ranges Goose Excel Discussion (Misc queries) 4 February 23rd 07 03:07 PM
Replace a spreadsheets named cells/ranges with exact cell address. David McRitchie Excel Discussion (Misc queries) 0 September 28th 05 08:59 PM
Replace a spreadsheets named cells/ranges with exact cell address. ExcelMonkey Excel Programming 4 September 16th 05 06:44 PM
Replace a spreadsheets named cells/ranges with exact cell address! ExcelMonkey Excel Programming 0 September 16th 05 12:21 PM


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