Help applying Macro to the whole Column

Alvaroro84

Board Regular
Joined
May 13, 2022
Messages
65
Office Version
  1. 2016
Platform
  1. Windows
Instead of applying it into on cell what can i change to apply it to the whole column?

VBA Code:
Sub Return_nth_character()
'declare variables
Dim ws As Worksheet
Set ws = Worksheets("sheet4")
'extract the 3rd character from a string
ws.Range("b1").EntireRow.Select = Mid(ws.Range("A1"), 3, 16)

End Sub
 
Last edited by a moderator:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Your code returns an error for me (you do not use a "Select" command in a line of code where you are setting a value equal to something).

Is this what you are looking for?
VBA Code:
Sub Return_nth_character()
'declare variables
Dim ws As Worksheet
Set ws = Worksheets("sheet4")
Dim lr As Long

'find last row in column A with data
lr = ws.Cells(Rows.Count, "A").End(xlUp).Row

'extract the 3rd character from a string
ws.Range("B1:B" & lr).Formula = "=Mid(A1, 3, 16)"
ws.Range("B1:B" & lr).Value = ws.Range("B1:B" & lr).Value

End Sub
 
Upvote 0
Solution
I accidently added ".EntireRow.Select" to see if it would do the whole row and that's why it ran an error. However, what you provided is exactly what I was looking for Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

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