Inserting Column then inserting Formula

joes2580

New Member
Joined
Feb 18, 2015
Messages
36
For example, I want to Insert a column to the Left Of column A first.

Next I want to take the data from Column B and do a =left on the first part and a =Mid on the second part (because the data is separated by a "/"; Part number on the left and description on the right.)

I was trying to do it like this:

Sub Inventory_Setup()


Worksheets(1).Range("a7:4000").Value = "=LEFT(B7,FIND(" / ",B7)-2)"

But I get a "Type Mismatch" error.


Any thoughts?
 
Last edited:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try this.

Test on a backup copy.

Code:
    Sheets(1).Range("A7:A4000").FormulaR1C1 = "=LEFT(RC[1],FIND("" / "",RC[1])-2)"


End Sub
 
Upvote 0
Running this code doesn't do anything. I forgot to mention I have it linked to a command button; not sure if it makes a difference.
 
Upvote 0
Try this:
Code:
Sub Inventory_Setup()

    Columns("A:A").Insert Shift:=xlToRight
    Sheets(1).Range("A7:A4000").FormulaR1C1 = "=LEFT(RC[1],FIND("" / "",RC[1])-2)"


End Sub

The RC is a reference to the rows and columns in relation to the cell with the formula.

So when cell A7 is populated it is looking for RC[1] which is one column to the right (B7)
 
Upvote 0
Let me give you the example:

Column A Column B
(Empty) 0078 / 63-80 TOYOTA LANDCRUISER FJ40 FRT/REAR 1 1/2" SHCKLE LIFT



I'm going to insert an additional Column to the Left of Column B also but the gist is I want the 0078 in Column A.

the info on the right side of the "/" in Column B. And I want do all of it in VBA.
 
Upvote 0

Forum statistics

Threads
1,214,608
Messages
6,120,500
Members
448,968
Latest member
screechyboy79

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