I have a large file of excel data where row data is not present under the relevant columns.
Name City School College Address
City:abc Name:abc College:abc Address:abc School: abc
City:abc College:abc Name:abc School: abc Address:abc
I have hundreds of such rows.
What I want is something like this :
Name City School College Address
Name:abc City:abc School:abc College:abc Address:abc
Name:abc City:abc School:abc College:abc Address:abc
I have identifiers before semicolon (:) in cell, but can't seem to match it to the column.
I have tried MATCH() Function for identifiers like School etc. but it can't work because Exact Match (Third field of MATCH() Function) won't work, other options can cause errors. Also Filter() doesn't seem to work either.
Kindly help me with an approach that can automate this. Can a formula be made for this or VBA code can work ?
I don't want to do so much manual work.
THANKS
EDIT
ANSWER:
Thanks Karpak for the answer. I just came up with the following solution before visiting your post.
For others, who are facing a similar problem, try this:
=INDEX(range, MATCH("SearcItem"&"*",Range,0), 1)
This will return the value of the cell after matching it up.
Happy Coding :)
Match with wildcard should work. Try with
=MATCH("Name:*",1:1,0)
=MATCH("College:*",1:1,0)
=MATCH("Address:*",1:1,0)
=MATCH("City:*",1:1,0)
=MATCH("School:*",1:1,0)
The above works for row 1. If you want to make it for row two replace 1:1 with 2:2 or if you want a specific cells, use A2:E2 etc.
Related
I am trying to have a macros that will pull numbers no matter where they are pasted. I am using index match to pull these from an input. I have been successful in finding the "Addresses" for what I am looking for. How do I get functions to reference the Address in the Cells and not the Cells themselves?
It is right on the tip of my tongue and it is maddening. When I put
Application.WorksheetFunction.Countif(Indirect(Address(5,9,True,"Sheet2")), Range("C1").Value)>0= True Then
There is a function error. When I put in
Application.WorksheetFunction.Countif(Variable.Address(Extrenal:=True), Range("C1").Value)>0= True Then
There is a mismatch error
I have tried Indirect(address()) but when I plug this into Index match it says that there is an error. Index(indirect(address()),Match(Ref,Indirect(Address),0))
I have also been trying to use the address in a countif statement.
If Application.WorksheetFunction.Countif(Indirect(Address(5,9,True,"Sheet2")), Range("C1").Value)>0= True Then...
Also,
(Index(indirect(address()),Match(Ref,Indirect(Address),0))
I am getting as mentioned a mismatch error and a function error. I will take any method to fix either of these.
thank you all for your input. This is what I came up with.Dim SKU as Range;Dim SKUR as Range;Dim SKU1 as String;Dim Variable as String;Dim VariableR as Range;Set SKU = Worksheets("Sheets1").Range("A:AC").Find("Number");Set SKUR =SKU.EntireColumn;Variable - SKUR.Address(External:=True);SetVariableR=Range(Variable);SKU1=Application.WorksheetFunction.IfError(Application.WorksheetFunction.Index(VariableR,(Application.WorksheetFunction.Match((Range("C1").Value),VariableR,0)),0);Worksheets("Sheet2").Range("C5").Value = SKU1
Again, this is what I came up for using index match in VBA using an address range I found.Some reason it won't let me post it with the spaces so I am using semi colons to separate lines, please take them out when using this.
I am trying to create a new variable called STREET NAME which will take a value of ON_STREET_NAME if it is not null or OFF_STREET_NAME if ON_STREET NAME is null.
I tried using
ifnull(on_street_name, off_street_name)
and
coalesce(on_street_name, off_street_name)
but none seemed to work. Any advice?
Ok, i was able to experiment different things and found this to work. Having null and empty space works differently. Here is the solution.
coalesce(nullif(on_street_name,''),off_street_name) as street_name
It works like magic :)
My sheet contains three types of cells:
5off
50off
550off
What they should read is:
$5.00 Off
$0.50 Off
$5.50 Off
I've been fighting with Text-to-Columns and =concat for a while and am trying to get this to work as easily as possible. Any ideas?
Just wondering what's the rule of the conversion for example the first figure is
5off => "$5.00 Off" > split number, add decimal, upper the O in off, concatenate
However in number two the rules are a little different
50off => "$0.50 Off" > split number, make the number decimal, concatenate
Based on those limited information I will suggest you to break down your problem to simpler form:
See image below, the top is the result, bottom is the formula used. There might be simpler way though.
Hope this help
I am new to PostgreSQL and decided to play around with it a little bit. Thus I want to extract Strings from a Marked-Up text, but I do not get the result I wanted.
To do that I have a simple table named book and a column with a text data type called page.
The data looks something like this:
Simon the Sorcerer is a [[teenager]] transported into a fantasy world as a
[[Sorcerer (person)|sorcerer]] dressed in a cloak and [[pointy hat]]; his
cloak and hat are purple in the first game, but change to red for the rest
of the series (aside from possible magical colour changes in the third game).
He must use his logic and magical skills to solve puzzles as he progresses
through the games.
Now I want to extract each String between the brackets [[ ]]. But how do I do that correctly? Or is that even possible without Plug-ins?
I tried different versions with LIKE which did not produce any results, e.g.:
SELECT * FROM book WHERE page LIKE '[[%]]';
SELECT * FROM book WHERE page LIKE '[[teenager]]';
...
I also played a bit with regex, but I only got the whole dataset back instead of the String between the brackets:
SELECT * from book where page ~ '[^[[]+(?=\]])';
Is there a solution for my problem? Help will be much appreciated!
Use the regexp_matches function:
select regexp_matches(page,'[^[[]+(?=\]])','g') from book
I want to update a database table field using another field in the same table. Currently I have this table called sources.
Name Code
In the name column I have values like this example :
' Deals On Wheels '
'Homesru - Abu Dhabi - Madinat Zayed Gold Centre'
And I am having this update statement :
UPDATE Sources
SET Code = REPLACE((LTRIM(RTRIM(Name))),' ','-')
the result is :
Deals-On-Wheels-Al-Aweer
which is fine.
but for second one I have this :
Homesru---Abu-Dhabi---Madinat-Zayed-Gold-Centre
I want it to be like this :
Homesru-Abu-Dhabi-Madinat-Zayed-Gold-Centre
How can I Achieve this ? Any Help is appreciated.
As suggested by #DanielE. my answer will point to a more global solution, in case you ever need to replace duplicated/triplicated/quadriplicated/... occurrences of a character on a string.
I'll not create a full solution for this issue, is a recurring question and there are really good solutions around already. Check these links:
SQL Server Central: remove spaces between specific character in a string?. This forum post will point to the next link I'm posting here. But is good to know what they are asking and answering.
Replace multiple spaces with new one but you can slightly modify it to replace any character you want.
You can also rely on this answer Find and remove repeated strings from Aaron Bertrand.
try
REPLACE((LTRIM(RTRIM(REPLACE((LTRIM(RTRIM(Name))),' - ','-')))),' ','-')
this will first replace ' - ' with just '-'
You might want to look into using a UDF to do a regular expression search and replace. See https://launchpad.net/mysql-udf-regexp