Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Defining a Variable Range

An alternative approach.

Turn on the macro recorder
select that range that contains values (or empty)--no formulas, right?
Edit|goto|special
check Constants and ok.

Now just those cells with something in them are selected.

Type the value that's in A1 into the formula bar. But hit ctrl-enter to fill
all those cells.

Turn off the macro recorder.

I got this as my recorded code:

Columns("B:B").Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.FormulaR1C1 = "main"

And you could make it nicer:

Columns("B:B").SpecialCells(xlCellTypeConstants, 23).value _
= Range("a1").value



John Baker wrote:

Hi:

I have a simple issue, and iIknow there is a solution. I have copied a cell value, and I
wish to put it in all the cells in a column that have a some value in them (i.e are not
blank). All cells with values are sequential. I have been trying to work with variables,
but somehow come unstuck. The code I have is as follows:

Range("P1").Select

Irow = ActiveCell.Row

Selection.End(xlDown).Select

Irowd = ActiveCell.Row

Range ("a1").select
activecell().copy
'This is where I try and select a range to paste into and it fails.

Range(Irow, Irowd).Select

'unfortunatley that does not work. I
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Help appreciated.

John Baker


--

Dave Peterson
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
Defining UserForm Caption from a Variable [email protected] Excel Worksheet Functions 1 January 3rd 07 02:30 PM
Defining a variable within a sub... aking1987[_3_] Excel Programming 1 November 11th 04 01:12 PM
Defining a variable within a sub... aking1987[_2_] Excel Programming 1 November 11th 04 12:32 PM
Defining a variable within a sub... aking1987 Excel Programming 1 November 11th 04 11:00 AM
Defining a Variable Stephen[_3_] Excel Programming 1 September 8th 03 11:33 PM


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