How to identify table data using merged cells?
I am trying to interpolate a value in the table. However since my column cells are merged together, my code won't read the values. So far whenever i unmerge those columns, it works completely fine and gives me the value i want. How do i integrate merged cells as a matrices?
Sub brent()
Dim i As Integer, j As Integer
Dim P As Single, P1 As Single, P2 As Single
Dim M As Single, M1 As Single, M2 As Single
Dim inputmat()
nrow = 29
ncol = 2
P = Range("Axial").Value
ReDim inputmat(nrow, ncol)
For i = 1 To nrow
For j = 1 To ncol
inputmat(i, j) = Cells(5 + i, 6 + j)
Next j
Next i
If (P > inputmat(1, 1)) Or (P < inputmat(nrow, 1)) Then Range("PM").Value =
"NG"
Else
For i = 1 To nrow - 1
If (P <= inputmat(i, 1)) And (P >= inputmat(i + 1, 1)) Then
P1 = inputmat(i, 1)
P2 = inputmat(i + 1, 1)
M1 = inputmat(i, 2)
M2 = inputmat(i + 1, 2)
End If
Next i
For i = 1 To nrow
M = M1 + (P - P1) * (M2 - M1) / (P2 - P1)
Next i
Range("PM").Value = M
End If
End Sub
I know that there is problem under the "input (i,j)= cells(5+i,6+j)"
Is there any way to read that black column between the merged cells?
excel vba
add a comment |
I am trying to interpolate a value in the table. However since my column cells are merged together, my code won't read the values. So far whenever i unmerge those columns, it works completely fine and gives me the value i want. How do i integrate merged cells as a matrices?
Sub brent()
Dim i As Integer, j As Integer
Dim P As Single, P1 As Single, P2 As Single
Dim M As Single, M1 As Single, M2 As Single
Dim inputmat()
nrow = 29
ncol = 2
P = Range("Axial").Value
ReDim inputmat(nrow, ncol)
For i = 1 To nrow
For j = 1 To ncol
inputmat(i, j) = Cells(5 + i, 6 + j)
Next j
Next i
If (P > inputmat(1, 1)) Or (P < inputmat(nrow, 1)) Then Range("PM").Value =
"NG"
Else
For i = 1 To nrow - 1
If (P <= inputmat(i, 1)) And (P >= inputmat(i + 1, 1)) Then
P1 = inputmat(i, 1)
P2 = inputmat(i + 1, 1)
M1 = inputmat(i, 2)
M2 = inputmat(i + 1, 2)
End If
Next i
For i = 1 To nrow
M = M1 + (P - P1) * (M2 - M1) / (P2 - P1)
Next i
Range("PM").Value = M
End If
End Sub
I know that there is problem under the "input (i,j)= cells(5+i,6+j)"
Is there any way to read that black column between the merged cells?
excel vba
What black column? You can easily check if the cells are merged - stackoverflow.com/questions/22075988/…
– Michal Rosa
Nov 15 '18 at 2:54
add a comment |
I am trying to interpolate a value in the table. However since my column cells are merged together, my code won't read the values. So far whenever i unmerge those columns, it works completely fine and gives me the value i want. How do i integrate merged cells as a matrices?
Sub brent()
Dim i As Integer, j As Integer
Dim P As Single, P1 As Single, P2 As Single
Dim M As Single, M1 As Single, M2 As Single
Dim inputmat()
nrow = 29
ncol = 2
P = Range("Axial").Value
ReDim inputmat(nrow, ncol)
For i = 1 To nrow
For j = 1 To ncol
inputmat(i, j) = Cells(5 + i, 6 + j)
Next j
Next i
If (P > inputmat(1, 1)) Or (P < inputmat(nrow, 1)) Then Range("PM").Value =
"NG"
Else
For i = 1 To nrow - 1
If (P <= inputmat(i, 1)) And (P >= inputmat(i + 1, 1)) Then
P1 = inputmat(i, 1)
P2 = inputmat(i + 1, 1)
M1 = inputmat(i, 2)
M2 = inputmat(i + 1, 2)
End If
Next i
For i = 1 To nrow
M = M1 + (P - P1) * (M2 - M1) / (P2 - P1)
Next i
Range("PM").Value = M
End If
End Sub
I know that there is problem under the "input (i,j)= cells(5+i,6+j)"
Is there any way to read that black column between the merged cells?
excel vba
I am trying to interpolate a value in the table. However since my column cells are merged together, my code won't read the values. So far whenever i unmerge those columns, it works completely fine and gives me the value i want. How do i integrate merged cells as a matrices?
Sub brent()
Dim i As Integer, j As Integer
Dim P As Single, P1 As Single, P2 As Single
Dim M As Single, M1 As Single, M2 As Single
Dim inputmat()
nrow = 29
ncol = 2
P = Range("Axial").Value
ReDim inputmat(nrow, ncol)
For i = 1 To nrow
For j = 1 To ncol
inputmat(i, j) = Cells(5 + i, 6 + j)
Next j
Next i
If (P > inputmat(1, 1)) Or (P < inputmat(nrow, 1)) Then Range("PM").Value =
"NG"
Else
For i = 1 To nrow - 1
If (P <= inputmat(i, 1)) And (P >= inputmat(i + 1, 1)) Then
P1 = inputmat(i, 1)
P2 = inputmat(i + 1, 1)
M1 = inputmat(i, 2)
M2 = inputmat(i + 1, 2)
End If
Next i
For i = 1 To nrow
M = M1 + (P - P1) * (M2 - M1) / (P2 - P1)
Next i
Range("PM").Value = M
End If
End Sub
I know that there is problem under the "input (i,j)= cells(5+i,6+j)"
Is there any way to read that black column between the merged cells?
excel vba
excel vba
edited Nov 15 '18 at 3:44
BigBen
6,3672619
6,3672619
asked Nov 15 '18 at 2:22
Tsendee TsTsendee Ts
1
1
What black column? You can easily check if the cells are merged - stackoverflow.com/questions/22075988/…
– Michal Rosa
Nov 15 '18 at 2:54
add a comment |
What black column? You can easily check if the cells are merged - stackoverflow.com/questions/22075988/…
– Michal Rosa
Nov 15 '18 at 2:54
What black column? You can easily check if the cells are merged - stackoverflow.com/questions/22075988/…
– Michal Rosa
Nov 15 '18 at 2:54
What black column? You can easily check if the cells are merged - stackoverflow.com/questions/22075988/…
– Michal Rosa
Nov 15 '18 at 2:54
add a comment |
1 Answer
1
active
oldest
votes
Sub FindMergedCells()
Dim tbl As Range, cll As Range
Dim i As Integer
i = 1
Set tbl = Range("A1:E4")
For Each cll In tbl
If cll.MergeCells Then
Cells(i, 7) = "Cell " & cll.Address & " is merged"
i = i + 1
End If
Next
End Sub
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311521%2fhow-to-identify-table-data-using-merged-cells%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sub FindMergedCells()
Dim tbl As Range, cll As Range
Dim i As Integer
i = 1
Set tbl = Range("A1:E4")
For Each cll In tbl
If cll.MergeCells Then
Cells(i, 7) = "Cell " & cll.Address & " is merged"
i = i + 1
End If
Next
End Sub
add a comment |
Sub FindMergedCells()
Dim tbl As Range, cll As Range
Dim i As Integer
i = 1
Set tbl = Range("A1:E4")
For Each cll In tbl
If cll.MergeCells Then
Cells(i, 7) = "Cell " & cll.Address & " is merged"
i = i + 1
End If
Next
End Sub
add a comment |
Sub FindMergedCells()
Dim tbl As Range, cll As Range
Dim i As Integer
i = 1
Set tbl = Range("A1:E4")
For Each cll In tbl
If cll.MergeCells Then
Cells(i, 7) = "Cell " & cll.Address & " is merged"
i = i + 1
End If
Next
End Sub
Sub FindMergedCells()
Dim tbl As Range, cll As Range
Dim i As Integer
i = 1
Set tbl = Range("A1:E4")
For Each cll In tbl
If cll.MergeCells Then
Cells(i, 7) = "Cell " & cll.Address & " is merged"
i = i + 1
End If
Next
End Sub
answered Nov 15 '18 at 4:41
Michal RosaMichal Rosa
1,3221814
1,3221814
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311521%2fhow-to-identify-table-data-using-merged-cells%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What black column? You can easily check if the cells are merged - stackoverflow.com/questions/22075988/…
– Michal Rosa
Nov 15 '18 at 2:54