Ignore blank cells

hezcal11

Board Regular
Joined
Jan 20, 2012
Messages
57
Hello,
I currently have a programme excel 2010 that allows people to enter their shift availability for the month which is then transferred to a master sheet on another sharepoint area. I am trying to automate it so that it can be changed each month without too much hassle. The problem I have is that the first of each month is usually a different day so when I transfer the information it can move out of synch with the master table. I have a table to explain. On this particular month the first is a wednesday, so when I transfer this information over I need the box with the x in it to be the first box on the new table, that is ignore the two yellow cells. This can only be for the first cells as there will be blank cells in the availability, the 3rd for example, but I need these gaps to remain.
I hope someone can help. I have probably made it sound more complicated than it is.

Thanks


Colin

[TABLE="width: 336"]
<TBODY>[TR]
[TD="class: xl65, width: 64, bgcolor: transparent"]M
[/TD]
[TD="class: xl65, width: 64, bgcolor: transparent"]T
[/TD]
[TD="class: xl65, width: 64, bgcolor: transparent"]W
[/TD]
[TD="class: xl65, width: 64, bgcolor: transparent"]T
[/TD]
[TD="class: xl65, width: 64, bgcolor: transparent"]F
[/TD]
[TD="class: xl65, width: 64, bgcolor: transparent"]S
[/TD]
[TD="class: xl65, width: 64, bgcolor: transparent"]S
[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"][/TD]
[TD="class: xl65, bgcolor: transparent"][/TD]
[TD="class: xl65, bgcolor: transparent"]1st
[/TD]
[TD="class: xl65, bgcolor: transparent"]2nd
[/TD]
[TD="class: xl65, bgcolor: transparent"]3rd
[/TD]
[TD="class: xl65, bgcolor: transparent"]4th
[/TD]
[TD="class: xl65, bgcolor: transparent"]5th
[/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: yellow"][/TD]
[TD="class: xl63, bgcolor: yellow"][/TD]
[TD="class: xl64, bgcolor: transparent"]X
[/TD]
[TD="class: xl64, bgcolor: transparent"]E
[/TD]
[TD="class: xl64, bgcolor: transparent"][/TD]
[TD="class: xl64, bgcolor: transparent"]B
[/TD]
[TD="class: xl64, bgcolor: transparent"]E[/TD]
[/TR]
</TBODY>[/TABLE]

[TABLE="width: 240"]
<COLGROUP><COL style="WIDTH: 48pt" span=5 width=64><TBODY>[TR]
[TD="class: xl66, width: 64, bgcolor: transparent"]W[/TD]
[TD="class: xl66, width: 64, bgcolor: transparent"]T[/TD]
[TD="class: xl66, width: 64, bgcolor: transparent"]F[/TD]
[TD="class: xl66, width: 64, bgcolor: transparent"]S[/TD]
[TD="class: xl66, width: 64, bgcolor: transparent"]S[/TD]
[/TR]
[TR]
[TD="class: xl66, bgcolor: transparent"]1st[/TD]
[TD="class: xl66, bgcolor: transparent"]2nd[/TD]
[TD="class: xl66, bgcolor: transparent"]3rd[/TD]
[TD="class: xl66, bgcolor: transparent"]4th[/TD]
[TD="class: xl66, bgcolor: transparent"]5th[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: transparent"]X[/TD]
[TD="class: xl65, bgcolor: transparent"]E[/TD]
[TD="class: xl65, bgcolor: transparent"]E[/TD]
[TD="class: xl65, bgcolor: transparent"]B[/TD]
[TD="class: xl65, bgcolor: transparent"] [/TD]
[/TR]
</TBODY>[/TABLE]
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Possibly something like below (please note I have assumed that you already have the top row in sheet 2 filled out and that you made a typo in your post and the order in the second table should be XEBE not XEEB).
Change the sheetnames to suit.

Code:
Sub XXX()
    Dim LstRw As Long, i As Long
    LstRw = Sheets("Sheet1").Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
    For i = 2 To LstRw
        Sheets("Sheet1").Rows(i).SpecialCells(xlCellTypeConstants, 23).Copy Sheets("Sheet2").Range("A" & Sheets("Sheet2").Rows.Count).End(xlUp).Offset(1)
    Next
End Sub
 
Last edited:
Upvote 0
Possibly something like below (please note I have assumed that you already have the top row in sheet 2 filled out and that you made a typo in your post and the order in the second table should be XEBE not XEEB).
Change the sheetnames to suit.

Code:
Sub XXX()
    Dim LstRw As Long, i As Long
    LstRw = Sheets("Sheet1").Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
    For i = 2 To LstRw
        Sheets("Sheet1").Rows(i).SpecialCells(xlCellTypeConstants, 23).Copy Sheets("Sheet2").Range("A" & Sheets("Sheet2").Rows.Count).End(xlUp).Offset(1)
    Next
End Sub

Thanks will give it a try. I'm amazed you could understand my ramblings!!!
 
Upvote 0
Actually after reading it again I don't think the macro will work for you as I think you meant your second table to look like...
Excel Workbook
ABCDE
1WTFSS
21st2nd3rd4th5th
3XEBE
Sheet4
 
Upvote 0
If my reading of the post is now correct try the code below on a copy of your workbook.

Code:
Sub XXX()
    Dim LstRw As Long, i As Long, lstCo As Long, x As Long, LstRW2 As Long
    Application.ScreenUpdating = 0

    With Sheets("Sheet1")

        LstRw = .Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
        lstCo = .Cells.Find(What:="*", SearchOrder:=xlColumns, SearchDirection:=xlPrevious, LookIn:=xlValues).Column

        x = .Rows(2).Find(What:="1st", After:=.Cells(2, lstCo), LookIn:=xlValues, _
                          LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext).Column

        LstRW2 = Sheets("Sheet2").Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1

        For i = 3 To LstRw

            .Range(.Cells(i, x), .Cells(i, lstCo)).Copy Sheets("Sheet2").Cells(LstRW2, 1)
            LstRW2 = LstRW2 + 1
        Next
    
    End With

    Application.ScreenUpdating = 1
End Sub
 
Upvote 0
I was too late to add this as an edit to my last post. :(

Obviously it is assuming you have the first 2 rows in Sheet2 already and please note that it searches for the text "1st" in Row 2 , Sheet1 so make sure that is your exact wording.
 
Upvote 0
I will adjust and try again. I did make a `mistake in the second table. Thanks for taking the time to amend it.
 
Upvote 0

Forum statistics

Threads
1,222,435
Messages
6,166,019
Members
452,008
Latest member
Customlogoflipflops

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