Hi Team,
I am adding data to dictionary and printing dictionary values to Range.
But text data getting pasted as number.how to retain it original value. Thanks
I am adding data to dictionary and printing dictionary values to Range.
But text data getting pasted as number.how to retain it original value. Thanks
VBA Code:
Sub Copy_Columns_with_Formatting()
Dim Cl As Range
Dim rng_total As Range
Dim rng_Team As Range
Set rng_Team = Range("A1:J1").Find("Team", lookat:=xlWhole)
Set rng_total = Range("A1:J1").Find("Test Century", lookat:=xlWhole)
Dim dict As New Scripting.Dictionary
With dict
For Each Cl In Range("b2", Range("b" & Rows.Count).End(xlUp))
.Item(Cl.Value) = Array(Cells(Cl.Row, rng_Team.Column), Cells(Cl.Row, rng_total.Column))
Next Cl
Range("G2:H" & dict.Count + 1).Value = Application.Index(dict.items, 0, 0)
End With
End Sub
Book3 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | |||
1 | Sr No | Player Name | Period | Team | Test Century | Player Name | Test Century | ||||
2 | 1 | Sachin Tendulkar | 1989–2013 | India | 51 | India | 51 | ||||
3 | 2 | Ricky Ponting | 1995–2012 | Australia | 41 | Australia | 41 | <==Text value converted into Number | |||
4 | 3 | Virat Kohli | 2008–2020 | India | 27 | India | 27 | While pasting from dictionary | |||
5 | 4 | Kumar Sangakkara | 2000–2015 | Sri Lanka | 38 | Sri Lanka | 38 | ||||
6 | 5 | Jacques Kallis | 1995–2014 | South Africa | 45 | South Africa | 45 | ||||
7 | 6 | Hashim Amla | 2004–2019 | South Africa | 28 | South Africa | 28 | ||||
8 | 7 | Mahela Jayawardene | 1997–2015 | Sri Lanka | 34 | Sri Lanka | 34 | ||||
9 | 8 | Brian Lara | 1990–2007 | West Indies | 34 | West Indies | 34 | ||||
10 | 9 | Rahul Dravid | 1996–2012 | India | 36 | India | 36 | ||||
11 | 10 | AB de Villiers | 2004–2018 | South Africa | 22 | South Africa | 22 | ||||
12 | 11 | David Warner | 2009–2020 | Australia | 24 | Australia | 24 | ||||
13 | 12 | Sanath Jayasuriya | 1989–2011 | Sri Lanka | 14 | Sri Lanka | 14 | ||||
14 | 13 | Chris Gayle | 1989–2011 | West Indies | 25 | West Indies | 25 | ||||
15 | 14 | Shivnarine Chanderpaul | 1989–2011 | West Indies | 30 | West Indies | 30 | ||||
16 | 15 | Ross Taylor | 1989–2011 | New Zealand | 7 | New Zealand | 7 | ||||
17 | 16 | Matthew Hayden | 1993–2009 | Australia | 30 | Australia | 30 | ||||
18 | 17 | Gary Kirsten | 1993–2004 | South Africa | 21 | South Africa | 21 | ||||
19 | 18 | Kane Williamson | 1993–2004 | New Zealand | 13 | New Zealand | 13 | ||||
20 | 19 | Adam Gilchrist | 1996–2008 | Australia | 17 | Australia | 17 | ||||
21 | 20 | Joe Root | 2004–2014 | England | 16 | England | 16 | ||||
22 | 21 | Kevin Pietersen | 2004–2014 | England | 23 | England | 23 | ||||
23 | 22 | Javed Miandad | 1975–1996 | Pakistan | 23 | Pakistan | 23 | ||||
Sheet1 |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
B2:B23 | Cell Value | duplicates | text | NO |