Copy data based on cell value with selection of what to copy

1Ronin

New Member
Joined
Aug 21, 2017
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hello,


I have one macro that is copy rows from a master sheet to another sheet depending on cell values from column D.
There is a link between the cell value (in my macro is now 10001) and sheet name (St1).
The values could variate from 10001/St1 .... 10010/St10.
My questions are:
- How could I have a message at beginning of macro to select/input a specific value (1...10) and avoid to change macro all time (by replacing 10001 with 10007 for example)?
- How could I have a message at beginning of macro to select/input to copy all data (1...10) and not only a single value (for ex. 10005)?


Code:
Sub Copy1ST()

'Select older extracted data a deletes them; to modfy size if anything changes
    Sheets("St1").Activate
    Range("B2:XFD2000").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.ClearContents
    
 
Set i = Sheets("Data")
Set e = Sheets("St1")
Dim d
Dim j
d = 1
j = 2


Do Until IsEmpty(i.Range("D" & j))


    If i.Range("D" & j) = "10001" Then
    d = d + 1
    e.Rows(d).Value = i.Rows(j).Value
       
    End If
    j = j + 1
Loop


'delete first column data not interesting for us
    Sheets("St1").Select
    Range("A2:A2000").Select
    Selection.Delete Shift:=xlToLeft
    Range("A2").Select




MsgBox "Done!!!"


End Sub


Thank you for your time.
 

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).
I've done the modification just before you send the reply...
Is working now Ok.

Thanks a lot for your help Fluff and vcoolio.
All the best.
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0
Hello 1Ronin,

Looks like Fluff took care of business whilst I was fast asleep!
Thanks for the feedback.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,215,065
Messages
6,122,944
Members
449,095
Latest member
nmaske

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