Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Joe Joe is offline
external usenet poster
 
Posts: 476
Default fill a variable sized range

I have data elements in cols AC:AF. Data will be in rows from 5 to whatever.
I need to add a value from another named cell in the worksheet into col AB.
How do I do it so I only add values in AB that have data in AC?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default fill a variable sized range

Have you tried using:

If activecell.offset(0,1).Value<"" then

Where activecell is the cell in column AB?

--
Frank

"Do or do not; There is no try"
-Yoda


"Joe" wrote:

I have data elements in cols AC:AF. Data will be in rows from 5 to whatever.
I need to add a value from another named cell in the worksheet into col AB.
How do I do it so I only add values in AB that have data in AC?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default fill a variable sized range

Your question is not clear to me. Initially you say you want to add a value
(singular) from a named cell (do you mean a cell with a Defined Name, or do
you just mean you want to specify the cell address?) but then you go on to
say you want to add values (plural) in AB that have data in AC... is there
any linkage between what you want to put in AB and what is in AC, or do you
just want to put the value(s?) in the first blank cell in AB where AC next
to it is not blank? I guess my main problem is I can't visualize your setup
from your description.

--
Rick (MVP - Excel)


"Joe" wrote in message
...
I have data elements in cols AC:AF. Data will be in rows from 5 to
whatever.
I need to add a value from another named cell in the worksheet into col
AB.
How do I do it so I only add values in AB that have data in AC?


  #4   Report Post  
Posted to microsoft.public.excel.programming
Joe Joe is offline
external usenet poster
 
Posts: 476
Default fill a variable sized range

I can use that but if I have that formula it create blank cells which i don't
want. If I have 5 active cells in AC I only what 5 values in AB so my
database doesn't have empty rows.


"Phuelgod" wrote:

Have you tried using:

If activecell.offset(0,1).Value<"" then

Where activecell is the cell in column AB?

--
Frank

"Do or do not; There is no try"
-Yoda


"Joe" wrote:

I have data elements in cols AC:AF. Data will be in rows from 5 to whatever.
I need to add a value from another named cell in the worksheet into col AB.
How do I do it so I only add values in AB that have data in AC?

  #5   Report Post  
Posted to microsoft.public.excel.programming
Joe Joe is offline
external usenet poster
 
Posts: 476
Default fill a variable sized range

I am using a macro to extract records from a database into columns AC:AF.
The number of records change based on criteria selection. I then need to add
another value (Defined Range Name) to each row in AB. The value will be the
same and is stored elsewhere in the worksheet. If AC:AF has 5 rows I only
want to put the AB value on those same 5 rows, if AC:AF has 10 rows I want to
add it to those 10 rows. So how to I control the macro to add the value in
AB for just those rows with a value in AC.

I hope that helps

"Rick Rothstein" wrote:

Your question is not clear to me. Initially you say you want to add a value
(singular) from a named cell (do you mean a cell with a Defined Name, or do
you just mean you want to specify the cell address?) but then you go on to
say you want to add values (plural) in AB that have data in AC... is there
any linkage between what you want to put in AB and what is in AC, or do you
just want to put the value(s?) in the first blank cell in AB where AC next
to it is not blank? I guess my main problem is I can't visualize your setup
from your description.

--
Rick (MVP - Excel)


"Joe" wrote in message
...
I have data elements in cols AC:AF. Data will be in rows from 5 to
whatever.
I need to add a value from another named cell in the worksheet into col
AB.
How do I do it so I only add values in AB that have data in AC?


.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default fill a variable sized range

Okay, I think I see what you want. Give this macro a try...

Sub FillColumnAB()
Dim X As Long, LastRow As Long
Const StartRow = 2 '<<==assumes Row 1 is a header row
LastRow = Cells(Rows.Count, "AC").End(xlUp).Row
Range("DefinedName").Copy Range("AB" & StartRow & ":AB" & LastRow)
End Sub

Change my example "DefinedName" to your own defined range name (make sure to
keep the quotes); change the StartRow constant if need as well.

--
Rick (MVP - Excel)


"Joe" wrote in message
...
I am using a macro to extract records from a database into columns AC:AF.
The number of records change based on criteria selection. I then need to
add
another value (Defined Range Name) to each row in AB. The value will be
the
same and is stored elsewhere in the worksheet. If AC:AF has 5 rows I only
want to put the AB value on those same 5 rows, if AC:AF has 10 rows I want
to
add it to those 10 rows. So how to I control the macro to add the value
in
AB for just those rows with a value in AC.

I hope that helps

"Rick Rothstein" wrote:

Your question is not clear to me. Initially you say you want to add a
value
(singular) from a named cell (do you mean a cell with a Defined Name, or
do
you just mean you want to specify the cell address?) but then you go on
to
say you want to add values (plural) in AB that have data in AC... is
there
any linkage between what you want to put in AB and what is in AC, or do
you
just want to put the value(s?) in the first blank cell in AB where AC
next
to it is not blank? I guess my main problem is I can't visualize your
setup
from your description.

--
Rick (MVP - Excel)


"Joe" wrote in message
...
I have data elements in cols AC:AF. Data will be in rows from 5 to
whatever.
I need to add a value from another named cell in the worksheet into col
AB.
How do I do it so I only add values in AB that have data in AC?


.


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
Using variable sized range in CountIf() [email protected][_2_] Excel Discussion (Misc queries) 1 October 24th 07 11:15 AM
Copy variable sized range to single column... Jed Excel Programming 1 February 22nd 07 06:31 AM
Getting values from a variable sized range into an array Ken Loomis Excel Programming 8 October 5th 04 09:04 AM
Variable sized combo box Bruce[_7_] Excel Programming 1 August 10th 04 09:28 AM
Summing a variable sized range programmatically Norma[_2_] Excel Programming 3 August 24th 03 07:31 PM


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