VBA Coding Help - somewhat complex

The Whale

New Member
Joined
Sep 26, 2011
Messages
23
Hey Guys,

I need some help on setting up a heavy macro that I'm basically trying to put together in pieces. I need some coding that will sort through column A for a chunk of cells with data in them under a cell with "SERIES" in it.

What code can I insert to make it so that for all given populated cells after "Series" but before the next cell labeled "Series" I can have the data in a given column (let's say column G) and the same row as the original cell referenced in column A. I then need to have that cell's data copied/inserted into another worksheet by referencing a date (year more specifically) in column A of the new worksheet that matches column N (same row as original cell reference) in the original worksheet.

I know that this is a rather complex request and that I may be phrasing this in a confusing way however any help would be greatly appreciated if you'll bear with me!

Thanks,
The Whale
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Maybe like this

Code:
Sub anystuff()
Dim F1 As Range, F2 As Range
Set F1 = Columns("A").Find(what:="Series", LookIn:=xlValues, lookat:=xlValues)
Set F2 = Columns("A").Find(what:="Series1", after:=F1, LookIn:=xlValues, lookat:=xlValues)
'
'F1 and F2 define your renge
'
End Sub
 
Upvote 0
could you clarify a bit on how exactly to format the inputs for this function? I'm a bit new to the coding that you're showing... help much appreciated
 
Upvote 0
could you clarify a bit on how exactly to format the inputs for this function? I'm a bit new to the coding that you're showing... help much appreciated

I'm not clearly understanding which rows from Column G you are want to copy once you find the text "SERIES".
If you post a screen shot it will help.

Using your description, I've taken a guess as to what the sheet looks like.
Even if this is incorrect, hopefully the image plus the corresponding code example below will help you follow one way to apply the code VoG provided.

Excel Workbook
ABCDEFGHIJKLMN
1Parts
2SERIES: ASpecs2001
3Part 111111
4Part 222222
5Part 333333
6SERIES: BSpecs2004
7Part 111111
8Part 222222
9Part 333333
Sheet1


Code:
Sub anystuff()
    Dim F1 As Range, F2 As Range
    Dim sYear As String, lRow As Long
   
'---Find first instance of "SERIES"
    Set F1 = Columns("A").Find(What:="SERIES", LookIn:=xlValues, LookAt:=xlPart)
    
'---Find second instance of "SERIES"
    Set F2 = Columns("A").Find(What:="SERIES", After:=F1, _
        LookIn:=xlValues, LookAt:=xlPart)
    
'---Get year in Col N
    sYear = Cells(F1.Row, "N")
    
'---Find matching row on other sheet
    lRow = Sheets("OtherSheet").Columns("A").Find(What:=sYear, _
            LookIn:=xlValues, LookAt:=xlWhole).Row
    
'---Copy Series data in Column G to Column B of Other Sheet
    Range(F1, F2.Offset(-1)).Offset(0, 6).Copy
    Sheets("OtherSheet").Cells(lRow, "B").PasteSpecial (xlPasteValues)
    
    Application.CutCopyMode = False
End Sub

After running macro, data is copied to the other sheet at Year 2001...

Excel Workbook
ABC
1Year
22000
3
4
5
6
72001Specs
811111
922222
1033333
11
122002
OtherSheet
 
Upvote 0

Forum statistics

Threads
1,224,581
Messages
6,179,668
Members
452,936
Latest member
anamikabhargaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top