Need to:
1. Find column with header title "quantity" (i.e. text in first row for that column is "quantity")
2. Dim the contents of the third row of that column as a string
Need to:
1. Find column with header title "quantity" (i.e. text in first row for that column is "quantity")
2. Dim the contents of the third row of that column as a string
Last edited by ks100; 01-02-2014 at 03:57 PM.
![]()
Sub ks100() Dim l As Long Dim strTest As String For l = 1 To Cells(1, Columns.Count).End(xlToLeft).Column If LCase(Cells(1, l).Value) = "quality" Then strTest = Cells(3, l).Value End If Next l End Sub
Thanks,
Solus
Please remember the following:
1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.Highlight the code in your post and press the # button in the toolbar.2. Show appreciation to those who have helped you by clickingbelow their posts.
3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.
"Slow is smooth, smooth is fast."
Perhaps:
![]()
Sub ks100zzaazzz() Dim x As String Application.ScreenUpdating = False Cells(1, 1).Select Do Until ActiveCell.Value = "Quantity" If ActiveCell.Column > ActiveSheet.UsedRange.Columns.Count Then Exit Do ActiveCell.Offset(, 1).Select Loop x = ActiveCell.Offset(2).Value Application.ScreenUpdating = True End Sub
You're welcome. Glad to help out and thanks for the feedback.
With find function:
![]()
Sub main() Dim rng As Range, str As String Set rng = Sheets(1).Rows(1).Find("quantity", , xlValues, xlWhole) 'may need to change sheet name If Not rng Is Nothing Then str = rng.Offset(2).Value End Sub
@JOHN H. DAVIS, you are the expert, but to minimize the interaction between VBA and Excel, generally I would not use activecell or select. Is there a specific reason for this?![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks