'Use cell value as worksheet name
Im new to VBA, and i have something i dont understand now.
I've been trying to copy Worksheets by only copying Cells with a specific colour in a cell below. I want to be able to change the worksheet using the same cells by typing in the worksheet name also in a cell below.
I already tried using CONCAT (WsName,rCell) but that didnt really work.
Here is what i also tried:
Function ColorReplicate(rColor As Range, WsName As String, rCell As Range)
Dim lCol As Long
Dim vResult
Dim ws As Worksheet
lCol = rColor.Interior.ColorIndex
Set ws = ws.Sheets(WsName)
If rCell.Interior.ColorIndex = lCol Then
vResult = ws.rCell
End If
ColorReplicate = vResult
End Function
I would really apreciate help.
Edit 09.05.2022
Example
=ColorReplicate($A$37;B2;C37)
=ColorReplicate(Cell with searched Colour; Set Cell to look foe in other ws; Cell with ws name in it)
If there are better ways to copy a worksheet this way i would love to hear so
Many thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|