LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default How to Offset to get past merged cells ?

I have a spreadsheet with a variety of cells, some of which are merged
(across variable number of columns) and in varying columns across the
worksheet. there are some constants, in that the first column of each
group does not contain merged cells (contains the Project Name in row
3), the next column may or may not contain merged cells, but the
common point in each set is in Row 20 in the column following the
Project Name column. I need to move 1 set of columns past this column
before I do my insert of the template columns.

How do I code the Offset to ignore the Merged (or not) columns ?

Sub AddTeam()
'
' AddTeam Macro
' Macro to add a new team to an existing project
'
whereami_Row = ActiveCell.Row
whereami_Col = ActiveCell.Column
whereislast_Col = ActiveSheet.Cells.Find(what:="*",
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column

If whereislast_Col < whereami_Col Then
MsgBox ("Cursor not within a project" & vbCrLf & _
"Select a cell within the project and try again")
Exit Sub
End If

If whereami_Col < 17 Then
MsgBox ("Cursor not within a project" & vbCrLf & _
"Select a cell within the project and try again")
Exit Sub
End If
Application.EnableEvents = False
Project_Name = 0
'*
'*** Loop until we get back to the project name column
'*
Do Until Project_Name = 1
If Not ActiveSheet.Cells(3, whereami_Col).Value = "" Then
Row3Value = ActiveSheet.Cells(3, whereami_Col).Value
Select Case Row3Value
Case "A", "C", "D", "G", "H", "N", "P", "R", "S", "T",
"X"
whereami_Col = whereami_Col - 1
Case "Status"
whereami_Col = whereami_Col - 1
Case Else
Project_Name = 1 ' found it
End Select
Else
whereami_Col = whereami_Col - 1
End If
Loop
ActiveSheet.Cells(20, whereami_Col).Select
'*
'*** Need to move across by 2 sets of columns,
'*** whether they are 3 merged columns or a single column
'*
whereami = ActiveCell.Address
Range(whereami).Offset(0, 2).Select ' always goes to the next
column
whereami = ActiveCell.Address
'*
'*** Copy and insert template columns
'*
Application.ScreenUpdating = False
Columns("A:B").Select
Selection.EntireColumn.Hidden = False
Selection.Copy
Columns(whereami_Col).Insert
Columns("A:B").Select
Selection.EntireColumn.Hidden = True
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

Thanks in advance for any help

Regards
Fred

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Offset every 27th row in a column that is 2 cells wide (merged cel KS Excel Worksheet Functions 4 March 19th 08 02:00 AM
Merged cells .Offset(row,Col) inconsistancies Roy Peck Excel Programming 1 March 7th 07 02:07 PM
Offset and Merged cells Jim[_7_] Excel Programming 3 October 13th 06 04:21 PM
Navigating with keyboard after using offset on merged cells Clayton McGuire Excel Programming 2 June 4th 04 12:16 PM
Offset function with merged cells MacroDaddy Excel Programming 1 January 8th 04 05:48 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"