Hi all trying to join SpecialCells(xlConstants) with SpecialCells(xlFormulas)

Pfereday

New Member
Joined
Mar 17, 2012
Messages
36
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Hi all I'm trying to join SpecialCells(xlConstants) with SpecialCells(xlFormulas) and no matter what I [/FONT]try I can only one or the other to work never both.

HTML:
Sub Done()
Dim NR As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
With Sheets("Your Quotation")
    NR = .Range("D" & .Rows.Count).End(xlUp).Row + 1
    If NR > 149 Then NR = NR + 1    .Range("C" & NR).Resize(, 1).Value = Range("B:C").Value
    
    
    Range("A:A").SpecialCells(xlConstants & xlFormulas).Offset(, 2).Copy .Range("C" & NR)
    Range("A:A").SpecialCells(xlConstants).Offset(, 3).Copy .Range("D" & NR)
    Range("E:E").SpecialCells(xlConstants).Offset(, 1).Copy .Range("D" & NR)
    
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
Beep
End Sub
 
If I could show you a screenshot it would be clear what I am trying to do, but unfortunately I am not at home by the pc and can't send a screenshot. Thanks for all the help will be back at the pc tomorrow and have another go at it.
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
[TABLE="width: 210"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD] a [/TD]
[TD][/TD]
[TD]Front elevation[/TD]
[/TR]
[TR]
[TD] a [/TD]
[TD][/TD]
[TD]Ground Floor[/TD]
[/TR]
[TR]
[TD] a [/TD]
[TD][/TD]
[TD]Three section bay[/TD]
[/TR]
[TR]
[TD] a [/TD]
[TD][/TD]
[TD]Left[/TD]
[/TR]
[TR]
[TD] a [/TD]
[TD][/TD]
[TD]Lounge[/TD]
[/TR]
</tbody>[/TABLE]
the A opposite the word left is produced by a formula all the other a are text
 
Upvote 0
With my suggestion from post#2 I got the results in col F.


Book1
ABCDEF
2aFront elevationFront elevation
3Ground FloorThree section bay
4aThree section bayLeft
5aLeftLounge
6aLoungeTom
7 Tom
Sheet2
Cell Formulas
RangeFormula
A4=IF(C4="Three section bay","a","")
A7=IF(C7="Fluff","a","")


Did you try Rick's suggestion in post#10?
 
Upvote 0
Code:
Sub Done()
Dim NR As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
With Sheets("Your Quotation")
    NR = .Range("D" & .Rows.Count).End(xlUp).Row + 1
    If NR > 149 Then NR = NR + 1
    .Range("C" & NR).Resize(, 1).Value = Range("B:C").Value
    
    
    Union(Range("A:A").SpecialCells(xlConstants), Range("A:A").SpecialCells(xlFormulas)).Offset(, 2).Copy Range("C" & NR)
    
    Range("A:A").SpecialCells(xlConstants).Offset(, 3).Copy .Range("D" & NR)
    
    Range("E:E").SpecialCells(xlConstants).Offset(, 1).Copy .Range("D" & NR)
    
    Range("A:A").SpecialCells(xlConstants).Offset(, 2).Copy .Range("C" & NR)
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
Beep
End Sub

still only coping the text A'S not copying the formula one
Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]=IF(C4 ="Three section bay","a","")[/FONT]
 
Upvote 0
There's a missing . on this line before the last Range
Code:
Union(Range("A:A").SpecialCells(xlConstants), Range("A:A").SpecialCells(xlFormulas)).Offset(, 2).Copy [COLOR=#ff0000].[/COLOR]Range("C" & NR)
 
Upvote 0
Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Union(Range("A:A").SpecialCells(xlConstants), Range("A:A").SpecialCells(xlFormulas)).Offset(, 2).Copy .Range("C" & NR)[/FONT]
altered the above to .range and now getting the five items but the last two are both lounge not left and lounge

[TABLE="width: 169"]
<colgroup><col></colgroup><tbody>[TR]
[TD]Front elevation[/TD]
[/TR]
[TR]
[TD]Ground Floor[/TD]
[/TR]
[TR]
[TD]Three section bay[/TD]
[/TR]
[TR]
[TD]Lounge[/TD]
[/TR]
[TR]
[TD]Lounge[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
That's probably because you're overwriting the results with this line
Code:
Range("A:A").SpecialCells(xlConstants).Offset(, 2).Copy .Range("C" & NR)
 
Upvote 0
Altered code to this
Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Sub Done()
Dim NR As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
With Sheets("Your Quotation")
    NR = .Range("D" & .Rows.Count).End(xlUp).Row + 1
    If NR > 149 Then NR = NR + 1[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]    .Range("C" & NR).Resize(, 1).Value = Range("B:C").Value
    
    
    Union(Range("A:A").SpecialCells(xlConstants), Range("A:A").SpecialCells(xlFormulas)).Offset(, 2).Copy .Range("C" & NR)
    
    Range("A:A").SpecialCells(xlConstants).Offset(, 3).Copy .Range("D" & NR)
    
    Range("E:E").SpecialCells(xlConstants).Offset(, 1).Copy .Range("D" & NR)
    
    
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
Beep
End Sub[/FONT]
but now no line space between the next lot thats copied
 
Upvote 0
I have no idea what you are trying to do & a lot of your code is simply overwriting what other lines of code have done.
If the last used row in col D is less than 150 you are not adding a blank row.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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