Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to grap the data from my search cell by cell and tell it where to
be copied to on a new worksheet. I have managed to get the data copied to the new sheet but it is not where I want it to be. Here is the code I have already gotten from here and modified it to try and accomplish what it is that I want. I do believe one of my problems is that the columns between the datasheet and the new sheet do not match. The data sheet has only 13 columns of data and the new sheet has 18 columns, part is due to 2 of the columns are going to get there data from another data sheet, but that is another problem for another day. Thank you all for any help with this dilema. Private Sub BtnGo_Click() Dim tRow() Dim WSNew As Worksheet 'Dim rng As Range Dim T As String Dim TS As String With Application .ScreenUpdating = False .EnableEvents = False End With 'creates a new sheet from the master sheet T = Me.CbxDept.Text Sheets("MASTER").Copy befo=Sheets(2) Set WSNew = ActiveSheet 'creates the name of 'WSNew' WSNew.Name = T 'assigns cell 'J2' equal to 'T' WSNew.Cells(2, 10) = T 'copies all data that matches 'T' to new sheet c = 1 Sheets("ProCode").Select Range("M2").EntireColumn.Select Selection.Find(What:=T, after:=ActiveCell, LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=True).Activate ReDim Preserve tRow(c) tRow(c) = ActiveCell.Row Do c = c + 1 Selection.FindNext(after:=ActiveCell).Activate ReDim Preserve tRow(c) tRow(c) = ActiveCell.Row Loop Until tRow(1) = tRow(c) 'Copy cells in column A:M to WSNew Set tCell = WSNew.Range("A5") ' First destination cell For R = 1 To c - 1 For Col = 1 To 13 Cells(tRow(c), Col).Copy Destination:=tCell Set tCell = tCell.Offset(0, 1) Next Set tCell = tCell.Offset(1, -(Col - 1)) ' Next row Next With Application .ScreenUpdating = True .EnableEvents = True End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro code to put series name next to individual line in line grap | Charts and Charting in Excel | |||
How do I rename an Excel worksheet when the feature is grap out? | Excel Worksheet Functions | |||
macro needed to copy blocks of cells across to list of cells down | Excel Programming | |||
Parameters are not allowed in queries that can't be displayed grap | Excel Discussion (Misc queries) | |||
a script/macro to copy a block of cells next to specified cells | Excel Programming |