I have been looking around and i cant seem to find the same flavor of question that I have lets say I have a worksheet that has two columns of data one column I apply a filter too and then use that to create worksheets. I want then to paste the values from the second column that to a matching worksheet
So if I had column a had values abccd
and column b had values name fluid id state county I want the code to look at name and paste it to the proper worksheet in this example it would be worksheet a for fluid it would be worksheet b and so on and so forth
i am thinking its a for each formula and then loop it so
Sub C2s()
Dim contr As Control
Dim RN As Range
Dim LR As Integer
LR = Sheet3.Range("A" & Rows.Count).End(xlUp).Row
RN = Sheet3.Range("B1:B" & LR)
For Each Cell In RN
If
End If
Next
End Sub
** Edited to fix column range being allocated
This is untested, but should give you the idea of how to loop and use the offset column to process your values. The SpecialCells(xlCellTypeVisible) means it will only process the filtered records in your selection
Dim MyCell As Range,
Dim MyRange As Range
Dim WorksheetToCopyTo as string
Dim LR As Integer
LR = Sheet3.Range("A" & Rows.Count).End(xlUp).Row
Set MyRange = Sheet3.Range("A1:A" & LR)
For Each MyCell In MyRange.SpecialCells(xlCellTypeVisible)
WorksheetToCopyTo = MyCell.offset(0,1)
Select Case WorksheetToCopyTo
Case "Fluid"
<do something here>
Case "County"
<do something here>
End Select
Next MyCell
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.