Horizontally align identical values in columns

sdspieg

Board Regular
Joined
Dec 9, 2013
Messages
98
I have a sheet with different columns containing lists of the names of academic journals as they were extracted from different datasets. See below. What I am trying to do is to create a worksheet in which identical or similar journals names (e.g. 'Cahiers du monder russe' in the highlighted example) are in the same row - case-insensitively. So in this case, row two would only have 'Ab imperio' in column F for WoS, with all other columns remaining empty because they do not have that journal. This would continue until we hit the Asia Europe Journal, for which columns D, E and F would be would be aligned in the same row. And so on until the last. Can any of the wizards here make that happen? Thanks!

SEE Journal List.xlsx
CDEF
1LensDimensionsScopusWoS
2Academic Journal of Russian StudiesAsia Europe JournalACTA ARCHAEOLOGICA ACADEMIAE SCIENTIARUM HUNGARICAEAB IMPERIO-STUDIES OF NEW IMPERIAL HISTORY AND NATIONALISM IN THE POST-SOVIET SPACE
3Acta Oeconomica PragensiaBaltic Yearbook of International Law OnlineANNALES-ANALI ZA ISTRSKE IN MEDITERANSKE STUDIJE - SERIES HISTORIA ET SOCIOLOGIAAJALOOLINE AJAKIRI-THE ESTONIAN HISTORICAL JOURNAL
4Ajalooline Ajakiri. The Estonian Historical JournalCahiers du monde russeASIA EUROPE JOURNALANALI ZAVODA ZA POVIJESNE ZNANOSTI HRVATSKE AKADEMIJE ZNANOSTI I UMJETNOSTI U DUBROVNIKU
5Alma mater. Vestnik Vysshey ShkolyCanadian Slavonic PapersAVIAKOSMICHESKAYA I EKOLOGICHESKAYA MEDITSINAANNALES-ANALI ZA ISTRSKE IN MEDITERANSKE STUDIJE-SERIES HISTORIA ET SOCIOLOGIA
6Annals of tha Japanese Association for Russian and East European StudiesCanadian-American Slavic StudiesAVTOMATIZATSIYA I SOVREMENNYE TEKHNOLOGIIANTHROPOLOGY AND ARCHEOLOGY OF EURASIA
7Anthropology and Archeology of EurasiaCentral Asian SurveyBALKAN SOCIAL SCIENCE REVIEWASIA EUROPE JOURNAL
8Baltic Journal of European StudiesCommunist and Post-Communist StudiesBULLETIN OF THE GEORGIAN NATIONAL ACADEMY OF SCIENCESBALTIC JOURNAL OF EUROPEAN STUDIES
9Baltic regionDemokratizatsiya The Journal of Post-Soviet DemocratizationBULLETIN OF THE TOMSK POLYTECHNIC UNIVERSITY GEO ASSETS ENGINEERINGBALTIC REGION
10Baltic Yearbook of International Law OnlineEurasian Geography and EconomicsCAHIERS DU MONDE RUSSEBULGARIAN HISTORICAL REVIEW-REVUE BULGARE D HISTOIRE
11Baltijskij regionEurope Asia StudiesCANADIAN SLAVONIC PAPERSBULLETIN OF THE SOUTH URAL STATE UNIVERSITY SERIES-MATHEMATICAL MODELLING PROGRAMMING & COMPUTER SOFTWARE
12BULLETIN of the L.N. GUMILYOV EURASIAN NATIONAL UNIVERSITY. POLITICAL SCIENCE. REGIONAL STUDIES. ORIENTAL STUDIES. TURKOLOGY SeriesHerald of the Russian Academy of SciencesCAUCASUS SURVEYBULLETIN OF THE TOMSK POLYTECHNIC UNIVERSITY-GEO ASSETS ENGINEERING
13Bulletin of Baikal State UniversityJournal of Baltic StudiesCENTRAL ASIA AND THE CAUCASUSBYLYE GODY
14Bulletin of Kemerovo State UniversityJournal of East European Management StudiesCENTRAL ASIAN SURVEYCAHIERS DU MONDE RUSSE
15Bulletin of Kemerovo State University. Series: Political, Sociological and Economic sciencesJournal of international area studiesCENTRAL EUROPEAN JOURNAL OF INTERNATIONAL AND SECURITY STUDIESCANADIAN SLAVONIC PAPERS
16Bulletin of Krasnoyarsk State Pedagogical University named after V.P. AstafievJournal of Southeast European and Black Sea StudiesCOMMUNIST AND POST-COMMUNIST STUDIESCENTRAL EUROPEAN JOURNAL OF ECONOMIC MODELLING AND ECONOMETRICS
17Bulletin of Nizhnevartovsk State UniversityMedjunarodni problemiCOURRIER DES PAYS DE L'ESTCOMMUNIST AND POST-COMMUNIST STUDIES
18Bulletin of the Moscow State Regional UniversityPost-Soviet AffairsCZECH JOURNAL OF INTERNATIONAL RELATIONSCOMMUNIST ECONOMIES & ECONOMIC TRANSFORMATION
19Bulletin of the Moskow State Regional UniversityProblems of Post-CommunismDEMOCRATIZATIONCONTEMPORARY EUROPE-SOVREMENNAYA EVROPA
20Bulletin of the South Ural State University Series «Social Sciences and the Humanities»Revolutionary RussiaDEMOKRATIZATSIYADEMOCRATIZATION
21Cahiers Du Monde RusseRussian and East European StudiesDOKLADY EARTH SCIENCESDIALOG SO VREMENEM-DIALOGUE WITH TIME
22Cahiers du monde russe : Russie, Empire russe, Union soviétique, États indépendantsRussian Education & SocietyEAST EUROPEAN POLITICSDREVNYAYA RUS-VOPROSY MEDIEVISTIKI
23Canadian Slavonic PapersRussian Politics and LawEAST EUROPEAN POLITICS AND SOCIETIESEAST EUROPEAN JEWISH AFFAIRS
Lens
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try this ,it is not very tidy but should do what you want:
VBA Code:
Sub test()
Dim outarr()
Set dict = CreateObject("scripting.dictionary")

lc = Cells(Rows.Count, "C").End(xlUp).Row
colcr = Range(Cells(1, 3), Cells(lc, 3))
ld = Cells(Rows.Count, "d").End(xlUp).Row
coldr = Range(Cells(1, 4), Cells(ld, 4))
le = Cells(Rows.Count, "e").End(xlUp).Row
coler = Range(Cells(1, 5), Cells(le, 5))
lf = Cells(Rows.Count, "F").End(xlUp).Row
colfr = Range(Cells(1, 6), Cells(lf, 6))

For i = 1 To lc
 dict(colcr(i, 1)) = 0
Next i
For i = 1 To ld
 dict(coldr(i, 1)) = 0
Next i
For i = 1 To le
 dict(coler(i, 1)) = 0
Next i
For i = 1 To lf
 dict(colfr(i, 1)) = 0
Next i

ReDim outarr(1 To dict.Count, 1 To 5)
  kk = 1
  For Each Key In dict.keys
    For i = 1 To lc
      If UCase(Key) = UCase(colcr(i, 1)) Then
       outarr(kk, 2) = (Key)
       Exit For
      End If
    Next i
    For i = 1 To ld
      If UCase(Key) = UCase(coldr(i, 1)) Then
       outarr(kk, 3) = (Key)
       Exit For
      End If
    Next i
   For i = 1 To le
      If UCase(Key) = UCase(coler(i, 1)) Then
       outarr(kk, 4) = (Key)
       Exit For
      End If
    Next i
    For i = 1 To lf
      If UCase(Key) = UCase(colfr(i, 1)) Then
       outarr(kk, 5) = (Key)
       Exit For
      End If
    Next i
    
    kk = kk + 1
  Next Key
With Worksheets("sheet2")
 Range(.Cells(1, 1), .Cells(dict.Count, 5)) = outarr
End With
End Sub
Note is pastes the result to sheet 2
 
Upvote 0
Wow. Looks impressive. But when I run it (Alt-F11 and then F5, I get this error
1591291658032.png
. What am I doing wrong?
 
Upvote 0
What value shows in colcr(i,1) when this occurs,
what is the value in variable i
when you get the error look at the value in lc, is it greater than 1
Have a look at the array colcr in the locals window and check that the values in the array are valid values. look at he value in the array corresponding to i
i.e use the debugger to find out what the error is.
All that line is trying to do is add the string which is in colcr(i,1) into the dictionary, your workhseet showed all values as being stringa so it shouldn't be a problem
 
Upvote 0
Thanks for sticking with me! So I'm trying to go line by line in debug. When I go step by step , the lines color yellow, but nothing happens in my worksheet that has the data (which is called 'All databases' btw - does that matter?). And when I come to that line, I just get the error box I copied into my previous message.
1591307539273.png
 
Upvote 0
The problem is very simple, your file has a different data layout than the layout you specified in your original post. In that post you showed data in column C to F. The file you sent has data in column C to E. Note this is one additional column and not in the same columns . SO the software works on the data as you originally specified. If you insert two columns to move the data across it will work, however it doesn't process the 5th column. If you want to copy the 5th columns all the software is written such that it process each column separately so just copy and paste each section dealing with column F and change it to column G .
 
Upvote 0
Sorry the previous comment should have said your new data is in columns A to E,
I forgot to say if you want to increase the number of columns you also need to increase the dimensions of the variant array outarr, change it from 1 to 5 to 1 to 6 an also where it is written back to the worksheet2
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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