mercredi 25 mars 2015

VBA looping in excel

I would like to create a for loop using string value for increment from the code below you will see that I have created an x = string and I want to change as a string to find multiple text into my sheet and then copy and paste into another sheet in specific cell location



Sub looping()

'Finalrow = Cells(Rows.Count, 1).End(xlUp).Row

x = "PS - Wtotl"
y = "DO-SSPop"

For s = x To Len(x)
Windows("usco2010.xlsx").Activate
Selection.Find(What:=x, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Cells.FindNext(After:=ActiveCell).Activate
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("usco2010.xlsx").Activate
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Next s

End Sub

Aucun commentaire:

Enregistrer un commentaire