USFengBULLS
Board Regular
- Joined
- May 7, 2018
- Messages
- 66
- Office Version
- 365
- Platform
- Windows
Hello all,
I have a code below that copies the contents in columns A, B and C to the next blank row. I also need this code to Duplicate/Rename the contents in Cell C with, preferably REV 1 after it. Basically here is the format the users will be putting in Column C: LEVEL 1/ AREA A/ RM 125
I would like this code to duplicate that but just put a REV 1 on the end and if there is already a REV 1 then Increment to REV 2 and so on. Something like this:
LEVEL 1/ AREA A/ RM 125
LEVEL 1/ AREA A/ RM 125/ REV 1
LEVEL 1/ AREA A/ RM 125/ REV 2
LEVEL 1/ AREA A/ RM 125/ REV 3
This code below id very close, when it copies down it does rename it with the "/ REV 1" at the end, but when I run it again on that same line it puts another / REV 1. its doing something like this:
LEVEL 1/ AREA A/ RM 125
LEVEL 1/ AREA A/ RM 125/ REV 1
LEVEL 1/ AREA A/ RM 125/ REV 1/ REV 1
LEVEL 1/ AREA A/ RM 125/ REV 1/ REV 1/ REV 1
Does anyone know how I can tweak this code to Increment the number instead of this +1 of each text string?
Public Sub REVISED(tRow As Double)
Dim erow As Double
Dim Dn As Range
Dim Rng As Range
'Copy Cells down to next Blank Row
erow = Sheets("DRAWING SCHEDULE").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
Range(Cells(tRow, 1), Cells(tRow, 3)).Copy Sheets("DRAWING SCHEDULE").Cells(erow, 1)
'Renames deplicate to REV #
Set Rng = Range(Range("C11"), Range("c" & Rows.Count).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng
If Not .Exists(Dn.Value) Then
.Add Dn.Value, 0
Else
If .Item(Dn.Value) = 0 Then
.Item(Dn.Value) = .Item(Dn.Value) + 1
Dn.Value = Dn.Value & "/ REV 1"
End If
End If
Next Dn
End With
End Sub
I have a code below that copies the contents in columns A, B and C to the next blank row. I also need this code to Duplicate/Rename the contents in Cell C with, preferably REV 1 after it. Basically here is the format the users will be putting in Column C: LEVEL 1/ AREA A/ RM 125
I would like this code to duplicate that but just put a REV 1 on the end and if there is already a REV 1 then Increment to REV 2 and so on. Something like this:
LEVEL 1/ AREA A/ RM 125
LEVEL 1/ AREA A/ RM 125/ REV 1
LEVEL 1/ AREA A/ RM 125/ REV 2
LEVEL 1/ AREA A/ RM 125/ REV 3
This code below id very close, when it copies down it does rename it with the "/ REV 1" at the end, but when I run it again on that same line it puts another / REV 1. its doing something like this:
LEVEL 1/ AREA A/ RM 125
LEVEL 1/ AREA A/ RM 125/ REV 1
LEVEL 1/ AREA A/ RM 125/ REV 1/ REV 1
LEVEL 1/ AREA A/ RM 125/ REV 1/ REV 1/ REV 1
Does anyone know how I can tweak this code to Increment the number instead of this +1 of each text string?
Public Sub REVISED(tRow As Double)
Dim erow As Double
Dim Dn As Range
Dim Rng As Range
'Copy Cells down to next Blank Row
erow = Sheets("DRAWING SCHEDULE").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
Range(Cells(tRow, 1), Cells(tRow, 3)).Copy Sheets("DRAWING SCHEDULE").Cells(erow, 1)
'Renames deplicate to REV #
Set Rng = Range(Range("C11"), Range("c" & Rows.Count).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng
If Not .Exists(Dn.Value) Then
.Add Dn.Value, 0
Else
If .Item(Dn.Value) = 0 Then
.Item(Dn.Value) = .Item(Dn.Value) + 1
Dn.Value = Dn.Value & "/ REV 1"
End If
End If
Next Dn
End With
End Sub