Dynamic Column lookup and value insertion


New Member
Jun 30, 2009

I have a question I'm hoping someone can give me an answer to.

I have a worksheet with column headings. What i want to do is after selecting some values in a different column and clicking a command button, it finds the column with a specified "target string" and then inserts a value in that column based on the row my initial value is in. So for example (these are all variable values), lets say there are columns A-Z. My initial values are in column X in rows 10-15. The column I'm interested in is Column B with header "Assignment". I need VB code that will look for the header "Assignment", find that column, then allow the rest of my vb code to spit values into the cells in that column offsetted with the rows that I initially selected. So if the code finds the "Assignment" header in lets say column D - values should start getting spitted out in cells(10,4) -> cells(15,4).

Another challenge is that the initial field of values that I have selected, must be selected at all times because the rest of my vb code relies upon the ActiveCell.Selection property.

Currently, If i select my initial values and run the rest of my code, it spits out values in a static column by doing a cell.offset(x,x).value command. Essentially, i want this static column output to be dynamic where it could be a column anywhere in the sheet and doesnt have to be in a specific position based on the offset.

Any help would be GREATLY appreciated.



New Member
Jun 30, 2009
If anyone wants to know how this is done, or has a similar problem, ill be happy to share the code.

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...