HUh? Don't understand why marco not working...

Guanjin Peter

Active Member
Joined
May 21, 2008
Messages
429
Hi, can someone exlpain to me why isn't it working?
I tried to change
newWB2.Sheets("Order Template").Range("D79:F79").Select
to
newWB2.Sheets("Order Template").Range("R" & nTotal & "C:R" & nTotal & "C").Select




Rich (BB code):
newWB2.Sheets("Order Template").Range("c3").Value = "=COUNTA(A:A)"
        nCus = newWB2.Sheets("Order Template").Range("c3").Value
        nTotal = nCus + 1
 
newWB2.Sheets("Order Template").Range("D79:F79").Select
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        Selection.Borders(xlEdgeLeft).LineStyle = xlNone
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        Selection.Borders(xlEdgeRight).LineStyle = xlNone
        Selection.Borders(xlInsideVertical).LineStyle = xlNone
        newWB2.Sheets("Sheet2").Delete
        newWB2.Sheets("Sheet3").Delete
 
Last edited:

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Looks like you're trying to use R1C1 notation when you can refer to the range directly:

Code:
newWB2.Sheets("Order Template").Range("D" & nTotal & ":F" & nTotal).Select

HTH,
 

Guanjin Peter

Active Member
Joined
May 21, 2008
Messages
429
thanks for the reply...I was stuck in this situation...

The columns isn't fixed. That's why I'm using R1C1 notation, cos they automatically define the columns for you...
For example it always starts at column D, but may not always end at column F. If the data expands until X, it'll be
newWB2.Sheets("Order Template").Range("D" & nTotal & ":X" & nTotal).Select

I tried to replace X with a number, but the formula doesn't work. Any idea how can I get around with this?
 

northwolves

Well-known Member
Joined
Jun 21, 2006
Messages
1,122
Code:
newWB2.Sheets("Order Template").[D1].offset(nTotal-1,0).resize(1,X-3).Select
Regards
Northwolves
 

Guanjin Peter

Active Member
Joined
May 21, 2008
Messages
429
THanks the for reply!

Didn't start a new topic because it's linked.
How do I insert an empty row right after that?
is it...offset...then .value = "" ?
 

northwolves

Well-known Member
Joined
Jun 21, 2006
Messages
1,122
THanks the for reply!

Didn't start a new topic because it's linked.
How do I insert an empty row right after that?
is it...offset...then .value = "" ?

Code:
newWB2.Sheets("Order Template").[D1].Offset(nTotal - 1, 0).Resize(1, X - 3).Select
Selection.Offset(1, 0).EntireRow.Insert Shift:=xlDown

Regards
Northwolves
 

Watch MrExcel Video

Forum statistics

Threads
1,122,233
Messages
5,594,964
Members
413,955
Latest member
FalcoDaz

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
Top