VBA ignore anything NOT text

deletedalien

Well-known Member
Joined
Dec 8, 2008
Messages
505
Office Version
  1. 2013
Platform
  1. Windows
Hi all:

i have the following Code

Code:
Private Sub summary()


    Set Rng = Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row)
    For Each c In Rng
        If c.Value <> "" And Not IsDate(c.Value) Then
            Name = c.Value
        
                 Else
            If c.Value <> "" Then c.Offset(1, -1) = Name
        End If
    Next c
End Sub

but i need it to ignore anything that is not text

my data in column "B" looks like this (starts in B3)

And i need it to move the campaign title (camp1, camp2, different canes not just camp) to column "A" right next to the green date cells,
So far it works BUT whenever it finds a Date instead of a campaign, it will copy the last date cell (in green) which is wrong. i tried adding if not istext but doesnt work, also tried adding, if isnot isnumeric but that one failed completely

And actually right now its not MOVING the campaign name but just copying it...


can you guys please help :)


Camp1
2015-06-09
*00:00- 00:30
*03:30 - 04:00
*04:00 - 04:30
2015-06-10
*02:00 - 02:30
*05:30 - 06:00
Camp2
2015-06-09
*06:00 - 06:30

<tbody>
</tbody>
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
This can probably be simplified a bit,

Code:
Option Explicit
Private Sub summary()
Dim rng As Range, c As Range, pName As String
Set rng = Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row)
    For Each c In rng
        If c.Value <> "" And Not IsDate(c.Value) Then
            If Not IsNumeric(Left(c.Value, 1)) Then
                pName = c.Value
                c.ClearContents
            Else
                c.Offset(0, -1) = pName
            End If
        End If
    Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,071
Messages
6,053,371
Members
444,658
Latest member
lhollingsworth

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