LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Set the copy to column to a variable

I am bogged down on how to use this formula...

=COLUMN(INDEX(B1:CZ1,MATCH(A2,B1:CZ1,0)))

To set these lines to the correct column number...

aScan.Cut Sheets("FBAout").Range("B" & Rows.Count).End(xlUp)(2)
Sheets("FBAout").Range("B" & Rows.Count).End(xlUp).Offset(, 1) = Date

Where the column number (2 to 104) can replace the "B".

Cell A2 on FBAout sheet is a drop down with 50+ sheet names.
I have MySheet working for the proper sheet to FIND the search value, but I need to return it to the column header holding the same sheet name as in the drop down in A2.

Can't figure how to use the formula value or write the code to the correct proper column on sheet FBAout.

I'm using a drop down because the sheet names are everything from a simple name like "X" to "Brown & 80%White Calfskin" so an input box and proper spelling would be a nightmare!

Thanks,
Howard


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A2")) Is Nothing Or Target.Cells.Count 1 Then Exit Sub
Application.EnableEvents = False


Dim LRow As Long
Dim aScan As Range 'look for this value in one of 50+ different sheets (A:B columns)
Dim cScan As String 'is sheet FBAout A5 scanned-in value
Dim MySheet As String


cScan = Sheets("FBAout").Range("A5")
MySheet = Worksheets("FBAout").Range("A2") ' drop down with all sheet names in CELL FBAout A2


If cScan = "" Then
Exit Sub
ElseIf IsNumeric(cScan) Then
cScan = Val(cScan) '/ converts a "text" number to a value
Else
'/ is text and that is okay
End If


With Sheets(MySheet)

LRow = Sheets(MySheet).Cells(Rows.Count, "A").End(xlUp).Row

Set aScan = Sheets(MySheet).Range("A2:B" & LRow).Find(What:=cScan, _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

If Not aScan Is Nothing Then
aScan.Cut Sheets("FBAout").Range("B" & Rows.Count).End(xlUp)(2)
Sheets("FBAout").Range("B" & Rows.Count).End(xlUp).Offset(, 1) = Date

ElseIf aScan Is Nothing Then
MsgBox " No match found."

End If

End With

Application.EnableEvents = True

End Sub
 
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
How do I pull variable URL from one column and download the contentto another column? pand0ra.usa Excel Programming 3 August 26th 09 11:38 PM
Copy variable sized range to single column... Jed Excel Programming 1 February 22nd 07 06:31 AM
copy a range with known start column to variable end column Matilda Excel Programming 2 August 2nd 06 04:55 PM
Offset from a variable column to a fixed column Kurt Barr Excel Programming 2 June 27th 06 05:45 PM
Sum cells based on a row variable and seperate column variable CheeseHeadTransplant Excel Worksheet Functions 10 September 23rd 05 06:59 PM


All times are GMT +1. The time now is 11:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"