Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Default worksheet column value 2

Status
Not open for further replies.

jmstarbuck

Programmer
Aug 11, 2003
90
US
I am exporting data to an excel worksheet. I would like to set default values for some of my columns, so that the user doesn't have to worry about those fields when he inserts a row.

Here's what I am doing now.
Code:
 With .Columns("A:A")
            With .Validation
                .Delete
                .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                   xlBetween, Formula1:=ProgramYearCmb
                .IgnoreBlank = True
                .InCellDropdown = True
                .InputTitle = ""
                '.ErrorTitle = ""
                .InputMessage = ""
                .ErrorMessage = "The value must be " & ProgramYearCmb & "."
                .ShowInput = True
                .ShowError = True
            End With
        End With

I found a reference to listdataformat.defaultvalue somewhere, but I can't figure out how it would fit in.

Is there a way to set a default value?

J
 

How would you do it if you were working directly with Excel?

Randy
 
I don't know. I tried to figure that out so that I could just record a macro to see the code. I must be missing something. This seems fundamental. Do you know how to do it in Excel?

J
 

I know of no way to set default values on indivdual cells in Excel when creating a new column.
My point being, if you can't do it in Excel, you probably can't do it from Access either.


Randy
 
Learned this one from Skip...
Create a list!

Code:
Workbooks("yerBook.xls").Sheets("yerSheet").ListObjects.Add (xlSourceRange, Range("A1:C2"), , xlYes).Name ="List1"
Range("A2").Formula = "=" & ProgramYearCmb
Range("C2").Formula = "=TODAY()" [green]'for example[/green]
[green]'Start filling in your data. Skip over the columns with formulas. The list will automatically expand as you fill the rows, and any column with formulas will fill new cells with the formula[/green]
 
Thanks, Gruuuu!

I just knew it had to be possible. Where there is code, there is a way!

J

 



Go Gruuuu! ==> *

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top