WardenBerret
New Member
- Joined
- Mar 2, 2016
- Messages
- 9
Hello!
this will be a tough one...
So I have workbook1 (wbThis) and workbook2 (wbTarget) and in wbThis' sheet I have some cells which are filled. These cells have the format of:
From A6
P2123: Begin procedure
A7
P1234: Code
A8
P4456-6: Document
|
|
|
|
|
|
|
V
A27
It continues like that. Now I have 2 issues.
1.
I want to copy the PXXXxX: (small x is like an arbitrary summation of - or _ or > etc etc) codes to wbTarget. This code varies as you can see but there will always be a "P" in the beginning and a ":" at the end. Regarding this, I have tried with the code:
However, as you may have noticed, I have not wrote the code where I want it to end on ":" and copy everything inbetween (incl "P" and ":").. I don't know how to code this and I would like your help. And also, a few comments whether the code is efficient will be highly appreciated.
2.
Now there is no way to that all cells of wbThis' range of A6 -> A27 will be filled everytime there's a new document and because I don't want unnecessary copy/pasting I want the script to stop the copy/pasting of PXXXxX: if there is no P. (if there is no P there is no PXXXxX and then the cell will be empty and therefore redundant)
I guess you can code this using else to the If statement above:
(i'm still learning vba so I'm not too familiar with statements)
These are my problems, and i would love some guidance.
Thanks.
this will be a tough one...
So I have workbook1 (wbThis) and workbook2 (wbTarget) and in wbThis' sheet I have some cells which are filled. These cells have the format of:
From A6
P2123: Begin procedure
A7
P1234: Code
A8
P4456-6: Document
|
|
|
|
|
|
|
V
A27
It continues like that. Now I have 2 issues.
1.
I want to copy the PXXXxX: (small x is like an arbitrary summation of - or _ or > etc etc) codes to wbTarget. This code varies as you can see but there will always be a "P" in the beginning and a ":" at the end. Regarding this, I have tried with the code:
Code:
Dim wbThis As Workbook
Dim wbTarget As Workbook
Dim rowRng As Integer
Dim targetRowRng As Integer
For rowRng 6 To 27
For targetRowRng 14 To 35
If Left((A:rowRng).Value,1) = "P" Then
wbThis.Sheets("Sheet1").Range(A:rowRng).Copy
wbTarget.Sheets("Sheet1").Range(E:targetRowRng).PasteSpecial
End If
However, as you may have noticed, I have not wrote the code where I want it to end on ":" and copy everything inbetween (incl "P" and ":").. I don't know how to code this and I would like your help. And also, a few comments whether the code is efficient will be highly appreciated.
2.
Now there is no way to that all cells of wbThis' range of A6 -> A27 will be filled everytime there's a new document and because I don't want unnecessary copy/pasting I want the script to stop the copy/pasting of PXXXxX: if there is no P. (if there is no P there is no PXXXxX and then the cell will be empty and therefore redundant)
I guess you can code this using else to the If statement above:
Code:
Else Pass
These are my problems, and i would love some guidance.
Thanks.