#1   Report Post  
Posted to microsoft.public.excel.misc
PaulW
 
Posts: n/a
Default VBA Code Errors

Sub Button4_Click()

Sheets("Calculations").Select
Dim curdate As String
Dim predate As String
curdate = Range("F18").Value
predate = Range("F17").Value
Workbooks.Open Filename:= _
"S:\ New\New Business All.xls"
Range("C3").Select
ActiveCell.FormulaR1C1 = "predate"
Range("D3:G3").Select
ActiveCell.FormulaR1C1 = "curdate"

This is the beginning part of a macro, if I have €œ around predate and
curdate they show as those words, when I dont they get put as 0.

Currently the values of these are April in F18 (curdate) and March in F17
(predate)

  #2   Report Post  
Posted to microsoft.public.excel.misc
WillR
 
Posts: n/a
Default VBA Code Errors

Why not just use

Range("C3").Value = predate

etc....

You also do not specify which Sheet should be populated with these values



--
Kind Regards,
Will Riley


"PaulW" wrote:

Sub Button4_Click()

Sheets("Calculations").Select
Dim curdate As String
Dim predate As String
curdate = Range("F18").Value
predate = Range("F17").Value
Workbooks.Open Filename:= _
"S:\ New\New Business All.xls"
Range("C3").Select
ActiveCell.FormulaR1C1 = "predate"
Range("D3:G3").Select
ActiveCell.FormulaR1C1 = "curdate"

This is the beginning part of a macro, if I have €œ around predate and
curdate they show as those words, when I dont they get put as 0.

Currently the values of these are April in F18 (curdate) and March in F17
(predate)

  #3   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default VBA Code Errors

Either declare them as dates

Dim curdate As Date
Dim predate As Date

or use the Text property

curdate = Range("F18").Text
predate = Range("F17").Text


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"PaulW" wrote in message
...
Sub Button4_Click()

Sheets("Calculations").Select
Dim curdate As String
Dim predate As String
curdate = Range("F18").Value
predate = Range("F17").Value
Workbooks.Open Filename:= _
"S:\ New\New Business All.xls"
Range("C3").Select
ActiveCell.FormulaR1C1 = "predate"
Range("D3:G3").Select
ActiveCell.FormulaR1C1 = "curdate"

This is the beginning part of a macro, if I have " around predate and
curdate they show as those words, when I don't they get put as 0.

Currently the values of these are April in F18 (curdate) and March in F17
(predate)



  #4   Report Post  
Posted to microsoft.public.excel.misc
PaulW
 
Posts: n/a
Default VBA Code Errors

Hi, I tried Range("C3").Value = predate
instead of

Range("C3").Select
ActiveCell.FormulaR1C1 = "predate"

And still end up with blank cells. I tried putting text instead of value
when assigning the variables as well, but that didn't help...

Sorry if i'm being a bit thick, i've only been using VBA a few days and just
about everything I do on it is recording macros, and copy and pasting it with
bits I find on this forum, which is where i'm getting all the variable stuff.

This macro is to update a spreadsheet which shows figures for the current
month. To make it easier to use I didn't want any links to outside sheets, so
do everything by copying and pasting to this sheet. The Macro is on a
"Calculation Sheet" which switches to a Calculation Tab, gathers the
information it needs, opens New Business All and pastes it in. The months
March and April are column headers compairing this months figures to last
months.

New Business All only has 1 sheet, and this is the sheet that wants
populating with this information.

"WillR" wrote:

Why not just use

Range("C3").Value = predate

etc....

You also do not specify which Sheet should be populated with these values



--
Kind Regards,
Will Riley


"PaulW" wrote:

Sub Button4_Click()

Sheets("Calculations").Select
Dim curdate As String
Dim predate As String
curdate = Range("F18").Value
predate = Range("F17").Value
Workbooks.Open Filename:= _
"S:\ New\New Business All.xls"
Range("C3").Select
ActiveCell.FormulaR1C1 = "predate"
Range("D3:G3").Select
ActiveCell.FormulaR1C1 = "curdate"

This is the beginning part of a macro, if I have €œ around predate and
curdate they show as those words, when I dont they get put as 0.

Currently the values of these are April in F18 (curdate) and March in F17
(predate)

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
Complicated If Then / V Lookup / Match Statement... ryesworld Excel Worksheet Functions 17 December 10th 05 02:09 PM
Need 2 add second then third code with first code in the Tab View nick s Excel Worksheet Functions 3 December 6th 05 02:20 AM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM
Concatinate a filename CLR Excel Discussion (Misc queries) 28 August 1st 05 11:45 PM
close form code tkaplan Excel Discussion (Misc queries) 1 June 3rd 05 10:49 PM


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