Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default Determining Column to Use

I'm not sure if that answers my question. I'm trying to discover what column to use, as the activecolumn will not the be the correct column. Instead I want to insert data into whichever column currently has the heading of, for example, "Name". So, I guess the idea is to figure out which column in row2, had the value of "Name" and then assign that column to a variable to be used throughout my code. I imagine this could be done using find, but I'm not certain how. Or maybe there are other ways

----- Frank Kabel wrote: ----

Hi Da
use something lik
cells(4,activecell.column).value="some value

-
Regard
Frank Kabe
Frankfurt, German


Dan wrote
I'm trying to avoid referencing specific columns in the VBA code fo
one of my documents, in case columns are added and whatnot. With on
of my bits of code, which adds the current date/time into th
currently selected cell, I am using this: I
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 don

depending on what column the VBA code is being activated in
Now, my question is, is there a way to take a similar approach t

adding information to cells in certain columns, using the header ro
to determine which column to insert the data? With this code, fo
ex
Rows("4").Columns("A").Value = New1.TxtNum.Tex
Rows("4").Columns("B").Value = New1.TxtName.Tex
Could I replace ("A") and ("B") with "whatever column has the heade

of 'Number'" and "whatever column has the header of 'Name'"
Thank



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
Determining if a value already exists in column(s) Rookie_User Excel Discussion (Misc queries) 0 October 3rd 06 05:32 PM
need help with determining a formula Cal Excel Worksheet Functions 2 November 11th 05 01:49 PM
Determining a Date Mark Excel Discussion (Misc queries) 1 July 1st 05 03:13 PM
Determining the age of an individual Craig Excel Discussion (Misc queries) 2 March 2nd 05 08:47 PM
determining last column jacqui Excel Programming 4 July 24th 03 09:38 PM


All times are GMT +1. The time now is 06:09 AM.

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"