LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
CB CB is offline
external usenet poster
 
Posts: 97
Default Problem programming a formula

Hi all,

I'm having an issue with a formula not working in VB code that work just
fine when entered into a given cell.

A little background firstIm importing into Excel data from a datalogger.
The year and Julian day are output from the logger as two separate fields. I
need to get the Julian day expressed as MMM-DD format. When I simply format
the cell with that format, the value is one day behind (and it shows a year
of 1900 when the cursor is actually in the cell). I did a little searching
and a found a formula on the net that works when typed into a cell.
Unfortunately, the formula is overwritten when the data is imported. Hence,
my need to enter it programmatically after the data has been imported.

Before any coding I took the following steps to test my formulas in a blank
worksheet
i) Year imported to A11
ii) Julian day imported to B11
iii) Had the following formula in C11:
=IF(B11<100,CONCATENATE(A11,"0",B11),CONCATENATE(A 11,B11))
iv) Had the following formula in D11: =RIGHT(C11,5)
v) Format cell E11 as MMM-DD and had the following formula in E11:
=("1/1/" &(IF(LEFT(D11,2)*1<20,2000,1900)+LEFT(D11,2)))+MOD (D11,1000)-1

This works perfectly. When I had a closer look at that last formula, I found
I could skip the last three steps and simply use the formula below to get
exactly the same result:

=("1/1/"&A11)+B11-1

For example, today is March 9, 2009. With 2009 in A11 and 68 (Julian day for
today) in B11, the resulting cell returns Mar-09 exactly what I want.

The problem arises when I try to get the same results programmatically. I
have the following line of code after my code for importing the data.

Range("b11").Value = "=("1/1/" & a11) + b11 - 1"

I get an error when compiling. It doesnt appear to like the quotation marks
inside the formula. The debugger stops on the first 1 in the formula and it
expects End of Statement.

What am I missing?

FWIW, I'll then be expanding this to apply to a range of cells in a column.

Thanks for any and all assistance!

Chris
 
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
Programming problem. JonathanW Excel Programming 1 May 7th 07 04:42 PM
problem programming outside the startevent [email protected] Excel Programming 0 February 6th 07 12:44 PM
Excel: VB Macro programming problem with formula writing d-cubed[_2_] Excel Programming 2 February 1st 07 07:25 PM
How would I do this programming problem? Brett Smith[_2_] Excel Programming 0 January 18th 06 12:50 AM
Excel programming problem Peter Hansson Excel Programming 2 November 9th 03 03:19 PM


All times are GMT +1. The time now is 08:58 PM.

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"