I need to place a zero-width space after each character within the texts in MS Excel document.
Two important conditions:
The target text is in Japanese and Chinese.
Text with Latin characters and numbers should not be affected. I.e. in mixed Asian\Latin cell only Asian characters have to be separated by those spaces.
Amount of texts is huge so it's a pain to put them in manually.
I tried to find any suitable VBA-module out, but with no success.
Maybe it's possible to perform such action in another application and then import the texts back to Excel? That's solution is also acceptable.
Thanks in advance.
P.S. Exceptions (Latin characters):
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Assuming:
U+200B
This little macro:
Sub dural()
Dim zws As String, A1 As String, L As Long, i As Long
Dim temp As String
zws = ChrW(8203)
A1 = Range("A1").Text
L = Len(A1)
For i = 1 To L
temp = temp & Mid(A1, i, 1) & zws
Next i
temp = Mid(temp, 1, Len(temp) - 1)
MsgBox A1 & vbCrLf & temp
Range("A2").Value = temp
End Sub
will produce:
NOTE:
The character may be zero-width, but not zero-length!
Related
I'm trying to merge 2 date columns (contains blanks cells) and extract the non-duplicates excluding the blank cells while sorted in ascending order.
However, I'm encountering error trying to do so. As excel took in the blank cells as data and extracted data in the end contains invalid info that were not found in either columns. The extracted data were not sort correctly too.
S1 Date
S1 Count
S2 Date
S2 Count
Overall Date
Overall Count
01/10/2021
56
01/10/2021
127
01/10/2021
183
02/10/2021
98
02/10/2021
125
02/10/2021
223
03/10/2021
122
03/10/2021
51
03/10/2021
173
04/10/2021
45
04/10/2021
54
04/10/2021
99
05/10/2021
81
05/10/2021
64
05/10/2021
145
06/10/2021
21
06/10/2021
87
06/10/2021
108
07/10/2021
84
07/10/2021
63
07/10/2021
147
08/10/2021
12
08/10/2021
79
08/10/2021
91
09/10/2021
63
09/10/2021
45
09/10/2021
108
10/10/2021
79
10/10/2021
81
10/10/2021
160
11/10/2021
65
11/10/2021
21
11/10/2021
86
12/10/2021
81
12/10/2021
121
12/10/2021
202
20/10/2021
71
14/10/2021
54
20/10/2021
204
21/10/2021
83
15/10/2021
97
21/10/2021
151
22/10/2021
127
16/10/2021
67
22/10/2021
205
23/10/2021
84
17/10/2021
98
23/10/2021
137
24/10/2021
121
18/10/2021
54
24/10/2021
144
25/10/2021
54
19/10/2021
62
25/10/2021
54
26/10/2021
58
20/10/2021
133
26/10/2021
58
27/10/2021
87
21/10/2021
68
27/10/2021
87
28/10/2021
64
22/10/2021
78
28/10/2021
102
29/10/2021
34
23/10/2021
53
29/10/2021
109
30/10/2021
120
24/10/2021
23
30/10/2021
184
31/10/2021
78
28/10/2021
38
31/10/2021
78
29/10/2021
75
00/01/1900
0
30/10/2021
64
14/10/2021
54
15/10/2021
97
16/10/2021
67
17/10/2021
98
18/10/2021
54
19/10/2021
62
Excel image- Error highlighted in yellow
The formula used was =SORT(IFERROR(IFERROR(INDEX(DateS1,MATCH(0,COUNTIF($F$3:F3,DateS1),0)),INDEX(DateS2,MATCH(0,COUNTIF($F$3:F3,DateS2),0))),""))
Really appreciate if anyone could help.
If you have Windows Excel, I suggest a different formula:
Data Range: G1:J100
L1: overallDate
L2: =SORT(UNIQUE(FILTERXML("<t><s>"&TEXTJOIN("</s><s>",TRUE,INDEX(G2:I100,SEQUENCE(99),{1,3}))&"</s></t>","//s")))
M2: =IF(L2="","", SUMIF($G$1:$G$100,L2,$H$1:$H$100)+SUMIF($I$1:$I$100,L2,$J$1:$J$100))
Results from L2 will SPILL down as far as needed
In L2 adjust the range reference and SEQUENCE count as appropriate for your data, or make them dynamic
Formula in M2 will need to be copied down
Edit: If you want an inclusive list of dates in the OverallDate column, consider:
L2: =LET(dates,INDEX(G2:I100,SEQUENCE(99),{1,3}),MIN(dates)-1 + SEQUENCE(1+MAX(dates)-MIN(dates)))
I have a dataframe that looks similar to below:
Wave A B C
340 77 70 15
341 80 73 15
342 83 76 16
343 86 78 17
I want to generate columns that will have all the possible combinations of the existing columns. I showed 3 cols here but in my actual data, I have 7 columns and therefore 127 total combinations. The desired output is as follows:
Wave A B C AB AC AD BC ... ABC
340 77 70 15 147 92 ...
341 80 73 15 153 95 ...
342 83 76 16 159 99 ...
I implemented a quite inefficient version where the user inputs the combinations (AB, AC, etc.) and a new col is created with the sum of the rows. This seems almost impossible to accomplish for 127 combinations, esp with descriptive col names.
Create a list of all combinations with chain + combinations from itertools, then sum the appropriate columns:
from itertools import combinations, chain
cols = [*df.iloc[:,1:]]
l = list(chain.from_iterable(combinations(cols, n+2) for n in range(len(cols))))
#[('A', 'B'), ('A', 'C'), ('B', 'C'), ('A', 'B', 'C')]
for items in l:
df[''.join(items)] = df.loc[:, items].sum(1)
Wave A B C AB AC BC ABC
0 340 77 70 15 147 92 85 162
1 341 80 73 15 153 95 88 168
2 342 83 76 16 159 99 92 175
3 343 86 78 17 164 103 95 181
You need to get the all combination first , then we just get the combination , and we need create the maps dict or Series
l=df.columns[1:].tolist()
l1=[list(map(list, itertools.combinations(l, i))) for i in range(len(l) + 1)]
d=[dict.fromkeys(y,''.join(y))for x in l1 for y in x ]
maps=pd.Series(d).apply(pd.Series).stack()
df.set_index('Wave',inplace=True)
df=df.reindex(columns=maps.index.get_level_values(1))
#here using reindex , get the order of your new df to the maps keys
df.columns=maps.tolist()
# here assign the new value to the column , since the order is same that why here I am assign it back
df.sum(level=0,axis=1)
Out[303]:
A B C AB AC BC ABC
Wave
340 77 70 15 147 92 85 162
341 80 73 15 153 95 88 168
342 83 76 16 159 99 92 175
343 86 78 17 164 103 95 181
i need help with some homework. they want me to make a 10x10 multiplication tables using multiple while loops and nesting. they want the user to be prompted for the first number for the row and column. so if the you give 3 for column and 12 for the row it would look like this:
3 4 5 6 7 8 9 10 11 12
--------------------------------------------------
12| 36 48 60 72 84 96 108 120 132 144
13| 39 52 65 78 91 104 117 130 143 156
14| 42 56 70 84 98 112 126 140 154 168
15| 45 60 75 90 105 120 135 150 165 180
16| 48 64 80 96 112 128 144 160 176 192
17| 51 68 85 102 119 136 153 170 187 204
18| 54 72 90 108 126 144 162 180 198 216
19| 57 76 95 114 133 152 171 190 209 228
20| 60 80 100 120 140 160 180 200 220 240
21| 63 84 105 126 147 168 189 210 231 252
this is what i found with the internet search help:
row = int(input("Enter the first row number: " ))
while(row <= 10):
column = int(input("Enter the frist column number: "))
while(column <= 10):
if(row+column==0):
print('{:4s}'.format(''),end = '') #corner
elif(row*column==0):
print('{:4d}'.format(row+column),end = '') # border
else:
print('{:4d}'.format(row*column),end = '') # table
column=column+1
print()
row=row+1
if anyone could help me i would be very thankful
It should look something more like this:
row1 = int(input("Enter the first row number: " ))
column1 = int(input("Enter the first column number: "))
# TODO: print header
for row in range(row1, row1 + 10):
for column in range(column1, column1 + 10):
# TODO
That is, you only prompt for input twice, not (1+N) times, and you use the built-in function range() to generate the lists of rows and columns to iterate over.
I have data in Excel like so:
Column1 Column2 Column3 Total
37 45 61
37 68 99
123 76 12
...
I want to produce the following:
Column1 Column2 Column3 Total
37 45 61 45, 68
37 68 99
123 76 12 76,...
...
If column1 of row1 has the same value with another row's column1 then put its column2 value in total with a comma.
Assuming 100 rows in total, please try:
=IF(ISERROR(MATCH(A2,A3:A$100,0)),"",B2&", "&VLOOKUP(A2,A3:B$100,2,0))
Assuming you have your column 1 sorted, guess this should work:
Cell D2 =IF(A2=A1,IF(D1="",C1&", "&C2,D1&", "&C2),"")
This is my test case... It gives the required total in the last repeated no. Hope its ok
C1 C2 C3 Tot
37 45 61
37 68 99 61,99
123 76 12
123 24 34 12,34
123 35 66 12,34,66
144 62 35
I have a source content as shown below
Name Age Month Maths Science Physics
John 21 1 80 88 76
John 21 2 89 99 78
John 21 3 76 76 89
John 21 4 78 78 90
John 21 5 88 89 96
Sara 22 1 76 76 89
Sara 22 2 78 78 90
Sara 22 3 88 89 96
Sara 22 4 76 76 89
Sara 22 5 78 78 90
and i am looking to create a pivot table in excel something like this.
Name John
Age All
Month 1 2 3 4 5
Maths 80 89 76 78 88
Science 88 99 76 78 89
Physics 76 78 89 90 96
Is this possible? Thanks for looking
On your destination sheet, select an empty range with the correct number of columns and rows.
On the Formulas ribbon, select Insert Function and then specify All Functions in the dialog box.
In the list of functions, select Transpose, and give the entire range from the source sheet that you wish to transpose;
Click OK - your data range should now be transposed on the destination sheet
Select the entire destination range and then on the Data Ribbon select Auto-Filter.
You can now filter on any of the columns as desired.
In the above answer, at step 3, you need to make the TRANSPOSE function an array formula. In other words, hit "C-S-E" -- Control-Shift-Enter. Then your function is surrounded by curly brackets indicating it is an array function.