Please ask for assistance to place Array

K0st4din

Active Member
Joined
Feb 8, 2012
Messages
488
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. 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

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
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hello,
maybe it's not clear what I'm trying to do.
Currently, this macro asks me which worksheet I want to put the results on.
For example: In which worksheet do you want to transfer the values ​​that are taken from sheet1? I write, for example, Peaches and the information is applied very correctly to the selected sheet.
I want to push the button without asking: Which sheet do you want the information to be applied to? but directly to put it in all worksheets with names .... Array ("Peaches", "Oranges", etc.)
I ask for some help on your part, I just do not know how to do it.
So how do I remove the question of which worksheet and replace it with my chosen worksheets?


Thank you in advance.
 
Upvote 0
Try
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
   Dim Sht 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))
   
   For Each Sht In Array("Peaches", "Oranges")
      ResultData = Sheets(Sht).Range("J2", Sheets(Sht).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
      Sheets(Sht).Range("P2").Resize(UBound(ResultData)).NumberFormat = "General"
      Sheets(Sht).Range("P2").Resize(UBound(ResultData)) = ResultData
   Next Sht
   On Error GoTo 0
   Exit Sub
NoSuchSheet:
   MsgBox "That sheet name does not exist!", vbCritical
End Sub
 
Upvote 0
SOLVED Re: Please ask for assistance to place Array

That's what I wanted to get.
Thank you so much.
I did not try it anyway, but it still did not happen to me.
You are the best of the best.
Bow to you :pray::pray:
 
Upvote 0
Re: SOLVED Re: Please ask for assistance to place Array

Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,216,165
Messages
6,129,250
Members
449,497
Latest member
The Wamp

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