![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | |
|
Registered User
Join Date: Oct 2009
Posts: 1
OS: xp
|
Spreadsheet Fun
Sorry if this is the wrong forum for this, I can't find one that fits it better.
Firstly, hello every one, I am new here. I have encountered a little conundrum. Alrighty, so I have a .csv spreadsheet which is one column of data; web addresses, in the following format. Quote:
A) The actual addresses that are most common (www.x.com/blablabla.html) B) The domains that are most common (www.x.com) Any ideas on how to do this quickly and efficiently? Last edited by SpicyCrab; 10-26-2009 at 03:40 PM. Reason: typo |
|
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Registered User
Join Date: Sep 2009
Posts: 13
OS: windows xp
|
Re: Spreadsheet Fun
I copied the urls WITHOUT DOUBLE QUOTE in column A from A1 down.
Then I wrote a few macros and combined them in one overall macro. the macros are given below the macro is using splitting the url by text to columns and copied from column B to right. Then the macro finds out the no. of occasions each text occurs and find out the max no. of occurrence and that is the common occurrence you can go throug the macros to follow my logic. I AM NOT SURE WHETHER THIS IS QUICK OR EFFICIENT. But it seems to work assumptions 1. The splitting(text to columns) of the url does not run more than the column I as I am doing something in column J in the "sub" macro "findcommondomain". 2. when urls are entered in A1 down there should not be any gap and the url entries should not have the double quotes IT IS ENOUsGH IF you RUN THE MACRO "macrooverall". Other sub macro must be in the vbeditor in the same module. If there is any bug post the code line where there is trouble and the error message. The macros are Code:
Sub findcommonurl()
Dim j As Integer, k As Integer, r As Range
Dim m(1 To 8) As Integer, x As String, y(1 To 8) As String
Dim z
j = Range("A1").End(xlDown).Row
Set r = Range(Range("A1"), Range("A1").End(xlDown))
For k = 1 To j
x = Cells(k, "A").Value
m(k) = WorksheetFunction.CountIf(r, x)
'MsgBox m(k)
y(k) = x
Next k
z = WorksheetFunction.Max(m)
MsgBox "common url is " & " " & y(z)
End Sub
Code:
Sub texttocolA()
Dim r As Range
Set r = Range(Range("A1"), Range("A1").End(xlDown))
r.TextToColumns Destination:=Range("B1"), DataType:=xlFixedWidth, _
OtherChar:="/", FieldInfo:=Array(Array(0, 1), Array(7, 1)), _
TrailingMinusNumbers:=True
End Sub
Code:
Sub texttocolC()
Dim r As Range
Set r = Range(Range("C1"), Range("c1").End(xlDown))
r.TextToColumns Destination:=Range("C1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=".", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1)), _
TrailingMinusNumbers:=True
Range(Range("a1"), Range("a1").End(xlToRight)).EntireColumn.AutoFit
End Sub
Code:
Sub findcommondomain()
Dim j As Integer, k As Integer, r As Range
Dim m(1 To 8) As Integer, x As String, y(1 To 8) As String
Dim z
j = Range("C1").End(xlDown).Row
Set r = Range(Range("c1"), Range("c1").End(xlDown))
For k = 1 To j
x = Cells(k, "c").Value & "." & Cells(k, "c").End(xlToRight).Value
'MsgBox x
Cells(k, "j") = x
Next k
Set r = Range(Range("J1"), Range("J1").End(xlDown))
For k = 1 To j
x = Cells(k, "J")
m(k) = WorksheetFunction.CountIf(r, x)
'MsgBox m(k)
y(k) = x
Next k
z = WorksheetFunction.Max(m)
'MsgBox z
If z > 1 Then
MsgBox "coomon domain is " & " " & y(z)
Else
MsgBox "no common domain"
End If
End Sub
Code:
Sub macrooverall()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Range("B1:J1").EntireColumn.Delete
texttocolA
texttocolC
findcommonurl
findcommondomain
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Last edited by venkat1926; 11-22-2009 at 01:20 AM. |
|
|
|
![]() |
| Thread Tools | |
|
|