Apply Formula to Entire Column that Already has Data

vitamin

New Member
Joined
Jun 10, 2014
Messages
10
Hi all,

I have a spreadsheet with a column containing URL's.

I'd like to apply a formula to the entire column so that, if a URL has a question mark, delete the question mark and everything right of it.

I found this formula: =LEFT(A1, FIND("?", A1&"?")-1)

Probably a basic question but, how to I apply this formula to an entire column that already has data (in this case the url)???

Thanks!

-Paul
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
You can't, a cell can contain data or a value, but not both.
You either put the formula in another, or you use a macro.
 
Upvote 0
If you're happy with a macro try
Code:
Sub vitamin()
    With Range("A1", Range("A" & Rows.Count).End(xlUp))
        .Value = Evaluate(Replace("if(@="""","""",left(@,find(""?"",@&""?"")-1))", "@", .Address))
    End With
End Sub
 
Upvote 0
You can't, a cell can contain data or a value, but not both.
You either put the formula in another, or you use a macro.

I see... thanks.

If I make an adjacent blank column, apply the aforementioned formula to the entire column and then paste the URL(s) into that new column, will that do the trick?

As for a macro, I'm 101 and that's a foreign language when it comes to Excel .. :)
 
Upvote 0
If you're happy with a macro try
Code:
Sub vitamin()
    With Range("A1", Range("A" & Rows.Count).End(xlUp))
        .Value = Evaluate(Replace("if(@="""","""",left(@,find(""?"",@&""?"")-1))", "@", .Address))
    End With
End Sub

Oh, I just saw this code AFTER posting my last comment! I'll learning a bit about macros and give it a try ... thank you.
 
Upvote 0
I see... thanks.

If I make an adjacent blank column, apply the aforementioned formula to the entire column and then paste the URL(s) into that new column, will that do the trick?
Nope fraid not, you could put the URLs into(for instance) col A & the formula in col B, then copy col B & paste as values and delete the other column.
 
Upvote 0
Nope fraid not, you could put the URLs into(for instance) col A & the formula in col B, then copy col B & paste as values and delete the other column.

Interesting...great brain food for thought. I'll try the options, cheers.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

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