Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Determining Column to Use
Hi Dan
use something like cells(4,activecell.column).value="some value" -- Regards Frank Kabel Frankfurt, Germany Dan wrote: I'm trying to avoid referencing specific columns in the VBA code for one of my documents, in case columns are added and whatnot. With one of my bits of code, which adds the current date/time into the currently selected cell, I am using this: If Rows("2").Columns(ActiveCell.Column).Value = "Out" Or _ Rows("2").Columns(ActiveCell.Column).Value = "Back" Then initialvar = "DD" I'm using similar code throughout, so that different things are done depending on what column the VBA code is being activated in. Now, my question is, is there a way to take a similar approach to adding information to cells in certain columns, using the header row to determine which column to insert the data? With this code, for ex: Rows("4").Columns("A").Value = New1.TxtNum.Text Rows("4").Columns("B").Value = New1.TxtName.Text Could I replace ("A") and ("B") with "whatever column has the header of 'Number'" and "whatever column has the header of 'Name'" ? Thanks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Determining if a value already exists in column(s) | Excel Discussion (Misc queries) | |||
need help with determining a formula | Excel Worksheet Functions | |||
Determining a Date | Excel Discussion (Misc queries) | |||
Determining the age of an individual | Excel Discussion (Misc queries) | |||
determining last column | Excel Programming |