ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can someone please tell this newb what he's doing wrong? (https://www.excelbanter.com/excel-programming/361546-can-someone-please-tell-newb-what-hes-doing-wrong.html)

SanFranGuy06

Can someone please tell this newb what he's doing wrong?
 
i can't get either of these to work :o(

Sub Format_Data()

Dim i As Long
i = 1
Do While Cells(2, i) < ""
If InStr(1, Cells(1, i), "Sedol", vbTextCompare) Then
Columns(i).Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Else
i = i + 1
End If
Loop

End Sub

----------------------------------------------------------------------------------------------------------------

Sub Format_Data2()

Dim rCell As Range, i As Long
i = 1
Do
Set rCell = Nothing
Set rCell = ActiveSheet.Columns(i).Find("Sedol", , xlValues,
xlPart)
If Not rCell Is Nothing Then
rCell.EntireColumn.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
End If
Loop While Not rCell Is Nothing
Exit Sub
NoneFound:
MsgBox "Sedols Not Found"

End Sub


Norman Jones

Can someone please tell this newb what he's doing wrong?
 
Hi SanFranGuy06,

I slightly adapted your first procedu

'=============
Public Sub Format_Data()
Dim i As Long

i = 2
Do While Cells(2, i).Value < ""
If InStr(1, Cells(1, i), "Sedol", vbTextCompare) Then
Columns(i).Cut
Columns("A:A").Insert Shift:=xlToRight
End If
i = i + 1
Loop

End Sub
'<<=============


---
Regards,
Norman



"SanFranGuy06" wrote in message
ups.com...
i can't get either of these to work :o(

Sub Format_Data()

Dim i As Long
i = 1
Do While Cells(2, i) < ""
If InStr(1, Cells(1, i), "Sedol", vbTextCompare) Then
Columns(i).Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Else
i = i + 1
End If
Loop

End Sub

----------------------------------------------------------------------------------------------------------------

Sub Format_Data2()

Dim rCell As Range, i As Long
i = 1
Do
Set rCell = Nothing
Set rCell = ActiveSheet.Columns(i).Find("Sedol", , xlValues,
xlPart)
If Not rCell Is Nothing Then
rCell.EntireColumn.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
End If
Loop While Not rCell Is Nothing
Exit Sub
NoneFound:
MsgBox "Sedols Not Found"

End Sub





All times are GMT +1. The time now is 07:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com