K0st4din
Well-known Member
- Joined
- Feb 8, 2012
- Messages
- 501
- Office Version
- 2016
- 2013
- 2011
- 2010
- 2007
- Platform
- Windows
Hello, everyone.
Thanks to the Rick Rothstein, this macro jumps through a sheet1 - because my database is located here.
This macro works super, super, very good, but please for your cooperation, help me to re-skip it (skip) sheet1, but fill in my worksheets.
I mean: Array ("Peaches", "Apples", "Oranges", etc.)
I beg you for your cooperation because I did all sorts of experiments I have thought of, but I can not change it.
Thank you in advance for your help!
Greetings
Thanks to the Rick Rothstein, this macro jumps through a sheet1 - because my database is located here.
This macro works super, super, very good, but please for your cooperation, help me to re-skip it (skip) sheet1, but fill in my worksheets.
I mean: Array ("Peaches", "Apples", "Oranges", etc.)
I beg you for your cooperation because I did all sorts of experiments I have thought of, but I can not change it.
Thank you in advance for your help!
Greetings
Code:
Sub proba_pari_za_edin_sheet()Dim X As Long, Z As Long, Answer As String, OutSheet As Worksheet, Parts() As String
Dim DataFind As Variant, DataReplace As Variant, ResultData As Variant
Const DataSheet As String = "Sheet1"
DataFind = Sheets(DataSheet).Range("V2", Sheets(DataSheet).Cells(Rows.Count, "V").End(xlUp))
DataReplace = Sheets(DataSheet).Range("W2", Sheets(DataSheet).Cells(Rows.Count, "W").End(xlUp))
On Error GoTo NoSuchSheet
Set OutSheet = Sheets(InputBox("In/for witch Sheet?", vbQuestion))
On Error GoTo 0
ResultData = OutSheet.Range("J2", OutSheet.Cells(Rows.Count, "J").End(xlUp))
On Error Resume Next
For X = 1 To UBound(ResultData)
Parts = Split(ResultData(X, 1), "+")
For Z = 0 To UBound(Parts)
Parts(Z) = Application.Lookup(Parts(Z), DataFind, DataReplace)
Next
ResultData(X, 1) = Join(Parts, "+")
Next
OutSheet.Range("P2").Resize(UBound(ResultData)).NumberFormat = "General"
OutSheet.Range("P2").Resize(UBound(ResultData)) = ResultData
On Error GoTo 0
Exit Sub
NoSuchSheet:
MsgBox "That sheet name does not exist!", vbCritical
End Sub