Using OFFSET and MATCH Functions in VBA

mArK_d

New Member
Joined
Mar 7, 2007
Messages
11
I hope someone could help me with this problem, I haven't included any of the code I've tried as it's so far off the mark you'd probable fall down laughing.

I have a sheet (DDE Sheet) which will contain a table of DDE links. The
table always starts from D7. The number of Columns may go as far as AZ and
the number of rows my go to 107.

The DDE links look like this

=the962|IQVALUE!'L13O011G5(Dv)'

where [G5] is the variable for the columns and [L13O011] is the variable
for the rows. (I already have code for finding and replacing the row
variable).
DDE Sheet AutoSave Master.xls
ABCDEFGHIJKL
1O
2UnitReferenceStatus
3LO0EnableHTCO1FaultHTCO2FaultVAV%
4LanOSIdentifier
5
6S2S3    
7=the962|IQVALUE!'L14O011S2(V)'=the962|IQVALUE!'L14O011S3(V)'
8L11O0111111#REF!
9L11O0121112#REF!
10L11O0131113#REF!
11L11O0141114#REF!
12L11O0151115#REF!
13L11O0161116#REF!
DDE Sheet 2


The code for this sheet is currently<font face=Courier New><SPAN style="color:#00007F">Private</SPAN><SPAN style="color:#00007F">Sub</SPAN> CommandButton2_Click()
frmOptions.Show<SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Sub</SPAN><SPAN style="color:#00007F">Private</SPAN><SPAN style="color:#00007F">Sub</SPAN> CommandButton4_Click()
frmNetwork.Show<SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Sub</SPAN><SPAN style="color:#00007F">Private</SPAN><SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target<SPAN style="color:#00007F">As</SPAN> Range)
  
  <SPAN style="color:#00007F">Dim</SPAN> myRow<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Long</SPAN>
  <SPAN style="color:#00007F">Dim</SPAN> myRng<SPAN style="color:#00007F">As</SPAN> Range
    
  <SPAN style="color:#00007F">If</SPAN> Target.Cells.Count > 1<SPAN style="color:#00007F">Then</SPAN><SPAN style="color:#00007F">Exit</SPAN><SPAN style="color:#00007F">Sub</SPAN>
  myRow = Target.Row

  <SPAN style="color:#00007F">If</SPAN> Application.Intersect(Range("b7:B150"), Target)<SPAN style="color:#00007F">Is</SPAN><SPAN style="color:#00007F">Nothing</SPAN><SPAN style="color:#00007F">Then</SPAN>

    <SPAN style="color:#00007F">Exit</SPAN><SPAN style="color:#00007F">Sub</SPAN>
  <SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">If</SPAN>
  
  

  <SPAN style="color:#00007F">Set</SPAN> myRng = Me.Range(Cells(myRow, "D"), Cells(myRow, "AT"))

  
  Application.EnableEvents =<SPAN style="color:#00007F">False</SPAN>
  myRng.Replace what:="L??O???", _
     Replacement:=Me.Cells(Target.Row, "a").Value, _
     LookAt:=xlPart, _
     SearchOrder:=xlByRows, _
     MatchCase:=<SPAN style="color:#00007F">False</SPAN>

  
  Target.Select
  Application.EnableEvents =<SPAN style="color:#00007F">True</SPAN>
  <SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Sub</SPAN></FONT>

I have another sheet (Link Refs) which contains all the various DDE links as
text strings (not currently active) using the G & 5 as row and column
references ie.

What I would like to do is, using the values in E6 and F6 on the DDE Sheet, find the coresponding string in the Link Refs sheet, Copy it then paste special - values to the coreesponding column on the DDE Sheet, in this case E and fill the column from row 7, with the same string down to the last entry in column C.

As the user moves to the next pair of columns, in this case G5 & H6
and enters a value like G and 2 the process is repeated for that pair of columns.

The final process to make these links live is to find and replace the = at
the begining of the string with =, this activates the link. I can probably
figure this bit out but as for the rest I've tried setting some DIM
statements to ranges and then use OFFSET, INDEX, Lookup, MATCH but I don't really know what I'm doing.


Thanks in advance to anyone who responds
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

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