Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Using Named Columns in a formula within a VBA Macro

Hi,
I have 2 columns, let's say A and B and I named them ColA and ColB
correspondingly.
I want to be able to write something like this:

Question #1:
Cell (10,10) = ColA+ColB

Question #2
ColB = ColA+1

Could some one provide the syntax for each of the above please?

Thank you much
ekareem
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Using Named Columns in a formula within a VBA Macro

By my interpretation of the questions:

A#1

ActiveSheet.Cells(10, 10) = WorksheetFunction.Sum(Range("ColA")) _
+
WorksheetFunction,Sum(Range("ColB"))

A#2

Is not logica if ColB is a name for a range of cells, it would generate and
error because it would be attempting to use an Object as a variable in one
case, or attempting to make several cells equal to a single value, which
would also throw an error A named range is nothing more than a string
variable for a range address. Therefore, it must be used in the same manner
as a range address..


"ekareem" wrote in message
...
Hi,
I have 2 columns, let's say A and B and I named them ColA and ColB
correspondingly.
I want to be able to write something like this:

Question #1:
Cell (10,10) = ColA+ColB

Question #2
ColB = ColA+1

Could some one provide the syntax for each of the above please?

Thank you much
ekareem



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Using Named Columns in a formula within a VBA Macro

On Jan 2, 3:04*am, "JLGWhiz" wrote:
By my interpretation of the questions:

A#1

ActiveSheet.Cells(10, 10) = WorksheetFunction.Sum(Range("ColA")) _
* * * * * * * * * * * * * * * * * * * * * * * *+
WorksheetFunction,Sum(Range("ColB"))

A#2

Is not logica if ColB is a name for a range of cells, it would generate and
error because it would be attempting to use an Object *as a variable in one
case, or attempting to make several cells equal *to a single value, which
would also throw an error *A named range is nothing more than a string
variable for a range address. *Therefore, it must be used in the same manner
as a range address..

"ekareem" wrote in message

...



Hi,
I have 2 columns, let's say A and B and I named them ColA and ColB
correspondingly.
I want to be able to write something like this:


Question #1:
Cell (10,10) = ColA+ColB


Question #2
ColB = ColA+1


Could some one provide the syntax for each of the above please?


Thank you much
ekareem- Hide quoted text -


- Show quoted text -


ABOUT Question #1: TRY THIS MAY BE HELPFUL

Sub SUMME()
Dim COLA, COLB As Range
Set COLA = Range("A:A")
Set COLB = Range("B:B")

ActiveSheet.Cells(10, 10) = Application.WorksheetFunction.Sum(COLA) _
+ Application.WorksheetFunction.Sum(COLB)
End Sub
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 or formula to compare columns and give a result of the odd o Rhett C[_2_] Excel Discussion (Misc queries) 2 December 24th 09 02:26 AM
Trying to use Lookup with Named Columns San Excel Worksheet Functions 1 January 23rd 07 09:35 AM
Named Range Macro Formula Martin Fishlock Excel Programming 2 December 22nd 06 01:14 AM
Named Range Macro Formula Gary Keramidas Excel Programming 0 December 21st 06 11:36 PM
How can I sum data on a row from certain named columns? Liliana Excel Worksheet Functions 1 May 11th 06 08:07 PM


All times are GMT +1. The time now is 03:45 AM.

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"