Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Missing cells

Hi!

I´d like to ask you for help. Is there a way how to solve this problem:
I have Excel files whose 1st column always contains these values (not
talking about cell adresses) in the same order:A1, A2, A3...A12, B1,
B2...B12, C1, C2...C12.
Sometimes, however, some value is missing. Let´s assume that there is no
A4 and no B6 and no C7. How should I create a macro that controls if any
of these values are missing, and if so, it inserts a new row with this
missing value.

Thanks a lot,
DaSo



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Missing cells

Alternative suggestion, rather than see what is missing, on workbook open,
always add them

Private Sub Workbook_Open()
Dim sValues As String
Dim aryValues
Dim i As Long

sValues =
"A1,A2,A3,A4,A5,A6,A7,A8,A9,A0,A11,A12,B1,B2,B3,B4 ,B5,B6,B7,B8,B9,B10,B11,B1
2, C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12"
aryValues = Split(sValues, ",")
With Worksheets("Sheet1")
.Columns("A:A").ClearContents
For i = 0 To UBound(aryValues)
.Cells(i + 1, "A").Value = aryValues(i)
Next i
End With

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"DaSo" wrote in message
...
Hi!

I´d like to ask you for help. Is there a way how to solve this problem:
I have Excel files whose 1st column always contains these values (not
talking about cell adresses) in the same order:A1, A2, A3...A12, B1,
B2...B12, C1, C2...C12.
Sometimes, however, some value is missing. Let´s assume that there is no
A4 and no B6 and no C7. How should I create a macro that controls if any
of these values are missing, and if so, it inserts a new row with this
missing value.

Thanks a lot,
DaSo



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Missing cells

Hi Bob, thanks for your tip. However, I´ve forgotten to mention that
there are some values also in other colums, which means that after
running this macro, some of the values will no longer be in the correct
row (when for example I have A1, A2,missing A3, A4...A12; I than run
macro and all the information within the row A4 will be a part of A3).
So what I would need in this case is to add a new row after A2.
Any suggestion?

Thanks,Dan



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Missing cells

How about

Private Sub Workbook_Open()
Dim sValues As String
Dim aryValues
Dim i As Long

sValues = "A1,A2,A3,A4,A5,A6,A7,A8,A9,A0,A11,A12,B1,B2,B3,B4 ,B5,B6, " & _
"B7,B8,B9,B10,B11,B12, C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12"
aryValues = Split(sValues, ",")
With Worksheets("Sheet1")

For i = 0 To UBound(aryValues)
If .Cells(i + 1, 1).Text < aryValues(i) Then
.Cells(i + 1, 1).EntireRow.Insert xlDown
.Cells(i + 1, 1).Value = aryValues(i)
End If
Next i

End With

End Sub

"DaSo" wrote:

Hi Bob, thanks for your tip. However, I4ve forgotten to mention that
there are some values also in other colums, which means that after
running this macro, some of the values will no longer be in the correct
row (when for example I have A1, A2,missing A3, A4...A12; I than run
macro and all the information within the row A4 will be a part of A3).
So what I would need in this case is to add a new row after A2.
Any suggestion?

Thanks,Dan



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Missing cells

Thanks a lot! Great!



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply
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
Right Click menu missing for cells Barry A&P Setting up and Configuration of Excel 1 July 1st 09 10:24 PM
Missing text in cells C Petrie Excel Discussion (Misc queries) 1 March 3rd 08 07:56 AM
Missing Cells nurato4e Excel Discussion (Misc queries) 0 December 8th 05 10:16 PM
Missing cells, But they're NOT hidden [email protected] Excel Worksheet Functions 2 December 7th 05 11:31 AM
assigning "missing value" to cells Clare Excel Discussion (Misc queries) 1 March 9th 05 08:34 PM


All times are GMT +1. The time now is 10:36 AM.

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

About Us

"It's about Microsoft Excel"