Help with Simplifying Code

caddraftsman

New Member
Joined
Sep 5, 2011
Messages
1
I have attached my code below, I found an example and made it fit what I needed to do. The code works but I was wondering if there is a way of simplifying it. As you can see below if it finds say 106 1/2 IRF i want it to put those four values on the same row in the specified column numbers. I really have no experience with coding and this code works it just seems like a lot of code that I hope can be shortened up. I work with csv files everyday in the surveying field and am trying to automate finding and replacing multiple entries of the same kind. In each file we might have 1000 to 2000 entries. Basically we are using old point descriptions and converting them to our standard description with attribute data. Also if you have any other suggestions I am all ears.

Thanks for your help in advance,

Justin

Sub Auto_Open()
'
' Auto_Open Macro
'
' Keyboard Shortcut: Ctrl+Shift+W
'
Dim limit As Long
Dim c As Long
limit = Cells(Rows.Count, 1).End(xlUp).Row
For c = 1 To limit
If Cells(c, 5) = "105 FND PK" Then Cells(c, 7) = "NAIL"
If Cells(c, 5) = "105 FND PK" Then Cells(c, 5) = "MON"
If Cells(c, 5) = "106 1/2 IRF" Then Cells(c, 7) = "REBAR"
If Cells(c, 5) = "106 1/2 IRF" Then Cells(c, 8) = "0.5"
If Cells(c, 5) = "106 1/2 IRF" Then Cells(c, 9) = "FND"
If Cells(c, 5) = "106 1/2 IRF" Then Cells(c, 5) = "MON"

Next c
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Well, you could do it this way...

Code:
Sub Auto_Open()
  '
  ' Auto_Open Macro
  '
  ' Keyboard Shortcut: Ctrl+Shift+W
  '
  Dim limit As Long
  Dim c As Long
  limit = Cells(Rows.Count, 1).End(xlUp).Row
  For c = 1 To limit
    If Cells(c, 5) = "105 FND PK" Then
      Cells(c, 7) = "NAIL"
      Cells(c, 5) = "MON"
    End If
    If Cells(c, 5) = "106 1/2 IRF" Then
      Cells(c, 7).Resize(, 3) = Array("REBAR", "0.5", "FDN")
      Cells(c, 5) = "MON"
    End If
  Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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