Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-24-2014, 07:54 PM
BobBridges's Avatar
BobBridges BobBridges is offline Workbook data Names in VBA are string only? Windows 7 64bit Workbook data Names in VBA are string only? Office 2010 32bit
Expert
Workbook data Names in VBA are string only?
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default Workbook data Names in VBA are string only?

I'm not sure how to entitle this thread, nor how to google for the answer. I don't use names much in Excel, but I have a situation where it seems useful and I want my program to use it too.

Now, a name can refer either to a range (eg Market!C8) or to a value (2100). I see in VBA that I can get my program to use the range just fine, for example
Code:
Set ro = ThisWorkbook.Names("cFuel").Range
Great, I can use that in a program. But when I want to use one that's just a scalar value, something curious happens. Maybe you already know what I'm going to say.

In my worksheet, for example, one formula refers to "RC5*RpPK". It works fine, multiplying the value in col 5 by 0.45 and displaying the numeric I want.

But in my VBA program, when I refer to Names("RpPK").Value, I get back a string "=.045". When I try adding 1 to it, I don't get 1.45, I get an error. I've tried various combinations, but all I get back is the string, not the value.

Now, this doesn't have to be a deal-breaker; I can always strip off the leading "=" and use a conversion function. But it seems silly; surely Excel has some method or property that just issues the numeric value rather than a string value. The worksheet has access to the numeric value; why wouldn't VBA?



Anyone know how to do this?
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Workbook data Names in VBA are string only? Way to search for a string in text file, pull out everything until another string? omahadivision Excel Programming 12 11-23-2013 12:10 PM
Replace contents form 1 workbook with another based on simular data shabbaranks Excel 1 12-05-2012 11:11 PM
Workbook data Names in VBA are string only? macro to transfer data from one workbook to another workbook virsojour Excel Programming 5 02-01-2011 08:58 PM
inserting a string of data into an MS Word table??? matto Word VBA 0 07-16-2010 09:35 AM
Workbook data Names in VBA are string only? How do I merge data from one sheet in a workbook out into multiple sheets nolesca Excel 4 06-07-2010 08:13 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:19 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft