Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Complicated If Then / V Lookup / Match Statement... | Excel Worksheet Functions | |||
Need 2 add second then third code with first code in the Tab View | Excel Worksheet Functions | |||
copying vba code to a standard code module | Excel Discussion (Misc queries) | |||
Concatinate a filename | Excel Discussion (Misc queries) | |||
close form code | Excel Discussion (Misc queries) |